|
| 1 | +# This worklflow will perform following actions when a release is published: |
| 2 | +# - Fetch Latest release. |
| 3 | +# - Build the latest docker image in production. |
| 4 | +# - Build release and commit to repo. |
| 5 | +# - Push the docker image to Github Artifact Registry-Prod. |
| 6 | +# - Rollout latest docker image to GKE. |
| 7 | +# |
| 8 | +# Maintainers: |
| 9 | +# - name: Nisha Sharma |
| 10 | + |
| 11 | + |
| 12 | +name : Build and Deploy to Prod |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: [prod-helm-deploy] |
| 17 | + |
| 18 | +env: |
| 19 | + DEPLOYMENT_NAME: nmrxiv-nmrium |
| 20 | + DOCKER_HUB_USERNAME : ${{ secrets.DOCKER_HUB_USERNAME }} |
| 21 | + DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }} |
| 22 | + REPOSITORY_NAME: nmrium-react-wrapper |
| 23 | + REPOSITORY_NAMESPACE: nfdi4chem |
| 24 | + |
| 25 | +jobs: |
| 26 | + setup-build-publish-deploy-prod: |
| 27 | + name: Deploy to prod |
| 28 | + if: github.ref == 'refs/heads/prod-helm-deploy' |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + |
| 33 | + |
| 34 | + # Login to Docker Hub |
| 35 | + - name: Log in to Docker Hub |
| 36 | + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a |
| 37 | + with: |
| 38 | + username: ${{ env.DOCKER_HUB_USERNAME }} |
| 39 | + password: ${{ env.DOCKER_HUB_PASSWORD }} |
| 40 | + |
| 41 | + #Fetch latest release |
| 42 | + - name: Fetch latest release |
| 43 | + id: fetch-latest-release |
| 44 | + |
| 45 | + with: |
| 46 | + myToken: ${{ github.token }} |
| 47 | + exclude_types: "draft|prerelease" |
| 48 | + view_top: 10 |
| 49 | + - name: "Print release name" |
| 50 | + run: | |
| 51 | + echo "tag_name: ${{ steps.fetch-latest-release.outputs.tag_name }}" |
| 52 | +
|
| 53 | + #Build and push Docker image to Docker Hub |
| 54 | + - name: Build and push Docker image |
| 55 | + uses: docker/build-push-action@v4 |
| 56 | + with: |
| 57 | + context: . |
| 58 | + file: ./Dockerfile.prod |
| 59 | + push: true |
| 60 | + build-args: | |
| 61 | + RELEASE_VERSION=${{ steps.fetch-latest-release.outputs.tag_name }} |
| 62 | + tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}, ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest |
| 63 | + username: ${{ env.DOCKER_HUB_USERNAME }} |
| 64 | + password: ${{ env.DOCKER_HUB_PASSWORD }} |
| 65 | + |
| 66 | + # Build npm for release |
| 67 | + - name: Build npm |
| 68 | + run: |- |
| 69 | + npm install |
| 70 | + # Build for main distribution |
| 71 | + VITE_BUILD_OUT_DIR=dist npm run build |
| 72 | + # Build for specific version |
| 73 | + VITE_BUILD_OUT_DIR=releases/${{ steps.fetch-latest-release.outputs.tag_name }} npm run build |
| 74 | + |
| 75 | + # Commit |
| 76 | + - name: Commit to repo |
| 77 | + |
| 78 | + with: |
| 79 | + default_author: github_actions |
0 commit comments