diff --git a/.github/workflows/release.yml b/.github/workflows/deploy-docs.yml similarity index 56% rename from .github/workflows/release.yml rename to .github/workflows/deploy-docs.yml index ea2e0909..2a7c7abb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,40 +1,76 @@ -name: Release +name: Deploy Docs on: push: + branches: [main] tags: ["v*"] + workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-release + group: ${{ github.workflow }}-${{ github.ref }}-deploy-docs cancel-in-progress: false jobs: - deploy-package: + deploy-docs-next: runs-on: ubuntu-latest env: - DOCKER_IMAGE: package - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + DOCKER_IMAGE: ghcr.io/${{ github.repository }}-docs:next steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 + - name: Login to GitHub container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Build docker image uses: docker/build-push-action@v2 with: context: . - load: true - cache-from: type=gha,scope=package - cache-to: type=gha,mode=max,scope=package + push: true + cache-from: type=gha,scope=docs-app + cache-to: type=gha,mode=max,scope=docs-app tags: ${{ env.DOCKER_IMAGE }} - - name: Create .npmrc file - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc - - name: Publish package to npm - run: docker run -v $(pwd)/.npmrc:/root/.npmrc $DOCKER_IMAGE make publish + file: ./docs.Dockerfile + run-docs-next: + needs: deploy-docs-next + runs-on: ubuntu-latest + env: + NAME: ui-react-docs-next + DOCKER_IMAGE: ghcr.io/${{ github.repository }}-docs:next + steps: + - name: executing remote ssh commands + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.KIBA_APP_BOX_URL }} + username: ${{ secrets.KIBA_APP_BOX_USER }} + key: ${{ secrets.KIBA_APP_BOX_SSH_KEY }} + port: ${{ secrets.KIBA_APP_BOX_PORT }} + envs: DOCKER_IMAGE,NAME + script_stop: true + script: | + url="ui-react-docs-next.kibalabs.com" + varsFile=~/.${NAME}.vars + docker pull ${DOCKER_IMAGE} + docker stop ${NAME} && docker rm ${NAME} || true + docker run \ + --name ${NAME} \ + --detach \ + --publish-all \ + --restart on-failure \ + --env NAME=${NAME} \ + --env VIRTUAL_HOST=${url} \ + --env LETSENCRYPT_HOST=${url} \ + --env-file ${varsFile} \ + ${DOCKER_IMAGE} deploy-docs: + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest env: DOCKER_IMAGE: ghcr.io/${{ github.repository }}-docs:latest steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Login to GitHub container registry uses: docker/login-action@v2 with: @@ -54,6 +90,7 @@ jobs: file: ./docs.Dockerfile run-docs: needs: deploy-docs + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest env: NAME: ui-react-docs @@ -83,17 +120,3 @@ jobs: --env LETSENCRYPT_HOST=${url} \ --env-file ${varsFile} \ ${DOCKER_IMAGE} - create-release: - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - name: Create Release - uses: actions/create-release@v1 - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c4a8c52d..371f1ece 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,20 +1,21 @@ -name: Deploy +name: Deploy Package on: push: branches: [main] + tags: ["v*"] workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-deploy cancel-in-progress: false jobs: - deploy-package-next: + deploy-package: runs-on: ubuntu-latest env: DOCKER_IMAGE: package NPM_TOKEN: ${{ secrets.NPM_TOKEN }} steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: # NOTE(krishan711): need full history to calculate difference fetch-depth: 0 @@ -34,60 +35,24 @@ jobs: - name: Create .npmrc file run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc - name: Publish next package to npm - if: steps.vars.outputs.commit_count != '0' + if: steps.vars.outputs.commit_count != '0' && github.ref == 'refs/heads/main' run: docker run -v $(pwd)/.npmrc:/root/.npmrc $DOCKER_IMAGE make NEXT_VERSION=${{ steps.vars.outputs.commit_count }} publish-next - deploy-docs-next: + - name: Publish package to npm + if: startsWith(github.ref, 'refs/tags/v') + run: docker run -v $(pwd)/.npmrc:/root/.npmrc $DOCKER_IMAGE make publish + create-release: + needs: deploy-package + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest - env: - DOCKER_IMAGE: ghcr.io/${{ github.repository }}-docs:next + permissions: + contents: write steps: - name: Check out the repo - uses: actions/checkout@v2 - - name: Login to GitHub container registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Build docker image - uses: docker/build-push-action@v2 - with: - context: . - push: true - cache-from: type=gha,scope=docs-app - cache-to: type=gha,mode=max,scope=docs-app - tags: ${{ env.DOCKER_IMAGE }} - file: ./docs.Dockerfile - run-docs-next: - needs: deploy-docs-next - runs-on: ubuntu-latest - env: - NAME: ui-react-docs-next - DOCKER_IMAGE: ghcr.io/${{ github.repository }}-docs:next - steps: - - name: executing remote ssh commands - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.KIBA_APP_BOX_URL }} - username: ${{ secrets.KIBA_APP_BOX_USER }} - key: ${{ secrets.KIBA_APP_BOX_SSH_KEY }} - port: ${{ secrets.KIBA_APP_BOX_PORT }} - envs: DOCKER_IMAGE,NAME - script_stop: true - script: | - url="ui-react-docs-next.kibalabs.com" - varsFile=~/.${NAME}.vars - docker pull ${DOCKER_IMAGE} - docker stop ${NAME} && docker rm ${NAME} || true - docker run \ - --name ${NAME} \ - --detach \ - --publish-all \ - --restart on-failure \ - --env NAME=${NAME} \ - --env VIRTUAL_HOST=${url} \ - --env LETSENCRYPT_HOST=${url} \ - --env-file ${varsFile} \ - ${DOCKER_IMAGE} + uses: actions/checkout@v4 + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create ${{ github.ref_name }} \ + --title "Release ${{ github.ref_name }}" \ + --generate-notes