From adf11f9d6e230d316842f33fd397023bc3003c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Tue, 5 Mar 2024 11:33:18 +0100 Subject: [PATCH] [#385] Refine GitHub Actions workflow for optimized Docker image handling Optimized the build-and-deploy GitHub Actions workflow to streamline the deployment process. Removed redundant `make docker-login` and `make build-[backend|frontend]` steps, focusing directly on pushing the pre-built Docker images with `make push-backend` and `make push-frontend`. Added a crucial verification step to ensure the deployment environment is properly defined, enhancing the reliability of the deployment pipeline. This update ensures a more efficient and error-resilient deployment process by minimizing unnecessary steps and reinforcing environmental checks. --- .github/workflows/build-and-deploy.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index cf86e31cc..b00dfc6a6 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -45,6 +45,7 @@ jobs: - name: Check environment exists run: | make check-env-defined + build_backend: name: Build and push backend Docker image if: ${{ ! inputs.skip_build }} @@ -69,9 +70,8 @@ jobs: aws-region: eu-west-1 - name: Build and push images run: | - make docker-login - make build-backend make push-backend + build_frontend: name: Build and push frontend Docker image if: ${{ ! inputs.skip_build }} @@ -99,11 +99,10 @@ jobs: GTM_ID: ${{ secrets.GTM_ID }} SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }} run: | - make docker-login if [[ "${{ inputs.environment }}" == "staging" ]]; then export DOMAIN=staging.govtool.byron.network; fi; if [[ "${{ inputs.environment }}" == "beta" ]]; then export DOMAIN=sanchogov.tools; fi; - make build-frontend make push-frontend + deploy: name: Deploy app needs: @@ -143,24 +142,11 @@ jobs: uses: webfactory/ssh-agent@v0.8.0 with: ssh-private-key: ${{ secrets.GHA_SSH_PRIVATE_KEY }} - - name: Prepare and upload app config - run: | - if [[ "${{ inputs.environment }}" == "staging" ]]; then export DOMAIN=staging.govtool.byron.network; fi; - if [[ "${{ inputs.environment }}" == "beta" ]]; then export DOMAIN=sanchogov.tools; fi; - export DOMAIN=${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network} - make prepare-config - make upload-config - - name: Destroy Cardano Node, DB sync and Postgres if required - if: ${{ inputs.resync_cardano_node_and_db }} - run: | - if [[ "${{ inputs.environment }}" == "staging" ]]; then export DOMAIN=staging.govtool.byron.network; fi; - if [[ "${{ inputs.environment }}" == "beta" ]]; then export DOMAIN=sanchogov.tools; fi; - make destroy-cardano-node-and-dbsync; - name: Deploy app run: | - make docker-login if [[ "${{ inputs.environment }}" == "staging" ]]; then export DOMAIN=staging.govtool.byron.network; fi; if [[ "${{ inputs.environment }}" == "beta" ]]; then export DOMAIN=sanchogov.tools; fi; + export DOMAIN=${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network} make deploy-stack - name: Reprovision Grafana run: | @@ -178,7 +164,9 @@ jobs: run: | if [[ "${{ inputs.environment }}" == "staging" ]]; then export DOMAIN=staging.govtool.byron.network; fi; if [[ "${{ inputs.environment }}" == "beta" ]]; then export DOMAIN=sanchogov.tools; fi; + export DOMAIN=${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network} make notify + deploy_without_build: name: Deploy app without building if: ${{ inputs.skip_build }}