From 6fe53f963e9db7a1fcd605af0fed865b6f40c488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Wed, 20 Mar 2024 11:59:31 +0100 Subject: [PATCH] [#498] Implement a workflow that triggers deployment to `dev` when a tag is created (from a specific pattern) The existing GitHub workflow has been modified to introduce automated triggering for deployments to the `dev` branch on the development server upon the creation of a new tag that matches the pattern `refs/tags/dev-`. The workflow can now distinguish between automated activation triggered by specific tag creation and manual activation by the user. By adding a new workflow configuration file, `.github/workflows/deploy-dev-from-tag.yml`, the automation process for deployments has been enhanced to react promptly to tag creation events following the specified pattern. Changes: - Created a new GitHub workflow configuration file, `deploy-dev-from-tag.yml`, to facilitate automated deployment activation based on tag creation matching the predefined pattern `refs/tags/dev-`. - Configured the workflow to differentiate between automated triggering upon tag creation and manual activation. - Updated the workflow to respond effectively to tag creation events following the specified pattern, ensuring seamless deployment processes and providing the flexibility of manual activation as required. --- .github/workflows/deploy-dev-from-tag.yml | 66 +++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/deploy-dev-from-tag.yml diff --git a/.github/workflows/deploy-dev-from-tag.yml b/.github/workflows/deploy-dev-from-tag.yml new file mode 100644 index 000000000..df9b4ba7f --- /dev/null +++ b/.github/workflows/deploy-dev-from-tag.yml @@ -0,0 +1,66 @@ +name: Build and deploy GovTool to DEV server +run-name: Deploy by @${{ github.actor }} + +on: + create: + +env: + ENVIRONMENT: "dev" + CARDANO_NETWORK: "sanchonet" + DOMAIN: "dev-sanchonet.govtool.byron.network" + +jobs: + deploy: + name: Deploy app + if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/dev-') + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./scripts/govtool + env: + DBSYNC_POSTGRES_DB: "cexplorer" + DBSYNC_POSTGRES_USER: "postgres" + DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb" + GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} + GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }} + GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} + NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }} + SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} + TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" + GTM_ID: ${{ secrets.GTM_ID }} + SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }} + PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + IP_ADDRESS_BYPASSING_BASIC_AUTH1: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH1 }} + IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-access-key-id: ${{ secrets.GHA_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.GHA_AWS_SECRET_ACCESS_KEY }} + aws-region: eu-west-1 + + - name: Login to AWS ECR + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: eu-west-1 + + - name: Setup SSH agent + uses: webfactory/ssh-agent@v0.8.0 + with: + ssh-private-key: ${{ secrets.GHA_SSH_PRIVATE_KEY }} + + - name: Deploy app + run: | + make --debug=b all + + - name: Reprovision Grafana + run: | + sleep 30 # give grafana time to start up + make --debug=b reload-grafana