diff --git a/.github/workflows/build-and-deploy-beta.yml b/.github/workflows/build-and-deploy-beta.yml new file mode 100644 index 000000000..d1686c772 --- /dev/null +++ b/.github/workflows/build-and-deploy-beta.yml @@ -0,0 +1,64 @@ +name: Build and deploy GovTool to BETA server +run-name: Deploy by @${{ github.actor }} + +on: + push: + branches: + - main + +env: + ENVIRONMENT: "beta" + CARDANO_NETWORK: "sanchonet" + DOMAIN: "sanchogov.tools" + +jobs: + deploy: + name: Deploy app + 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 }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + 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 diff --git a/.github/workflows/build-and-deploy-dev.yml b/.github/workflows/build-and-deploy-dev.yml new file mode 100644 index 000000000..63cb63cf6 --- /dev/null +++ b/.github/workflows/build-and-deploy-dev.yml @@ -0,0 +1,62 @@ +name: Build and deploy GovTool to DEV server +run-name: Deploy by @${{ github.actor }} + +on: + workflow_dispatch: + +env: + ENVIRONMENT: "dev" + CARDANO_NETWORK: "sanchonet" + DOMAIN: "dev-sanchonet.govtool.byron.network" + +jobs: + deploy: + name: Deploy app + 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 }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + 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 diff --git a/.github/workflows/build-and-deploy-staging.yml b/.github/workflows/build-and-deploy-staging.yml new file mode 100644 index 000000000..bf713bf49 --- /dev/null +++ b/.github/workflows/build-and-deploy-staging.yml @@ -0,0 +1,64 @@ +name: Build and deploy GovTool to STAGING server +run-name: Deploy by @${{ github.actor }} + +on: + push: + branches: + - staging + +env: + ENVIRONMENT: "staging" + CARDANO_NETWORK: "sanchonet" + DOMAIN: "staging.govtool.byron.network" + +jobs: + deploy: + name: Deploy app + 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 }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + 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 diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml new file mode 100644 index 000000000..4b4070f98 --- /dev/null +++ b/.github/workflows/build-and-deploy-test.yml @@ -0,0 +1,64 @@ +name: Build and deploy GovTool to TEST server +run-name: Deploy by @${{ github.actor }} + +on: + push: + branches: + - test + +env: + ENVIRONMENT: "test" + CARDANO_NETWORK: "sanchonet" + DOMAIN: "test-sanchonet.govtool.byron.network" + +jobs: + deploy: + name: Deploy app + 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 }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + 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 diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/resync-cardano-node-and-db-sync.yml similarity index 62% rename from .github/workflows/build-and-deploy.yml rename to .github/workflows/resync-cardano-node-and-db-sync.yml index a7b892b9b..7bc2d0e21 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/resync-cardano-node-and-db-sync.yml @@ -1,15 +1,9 @@ -name: Build and deploy app -run-name: Deploy to ${{ inputs.environment }}/${{ inputs.cardano_network }} by @${{ github.actor }} +name: Re-sync Cardano Node and Cardano DB Sync +run-name: Cardano re-sync on ${{ inputs.environment }} by @${{ github.actor }} on: workflow_dispatch: inputs: - cardano_network: - required: true - type: choice - default: "sanchonet" - options: - - "sanchonet" environment: required: true type: choice @@ -19,18 +13,14 @@ on: - "test" - "staging" - "beta" - resync_cardano_node_and_db: - required: true - type: boolean - default: false env: ENVIRONMENT: ${{ inputs.environment || 'dev' }} - CARDANO_NETWORK: ${{ inputs.cardano_network || 'sanchonet' }} + CARDANO_NETWORK: "sanchonet" jobs: deploy: - name: Deploy app + name: Re-sync Cardano state runs-on: ubuntu-latest defaults: run: @@ -71,26 +61,10 @@ jobs: with: ssh-private-key: ${{ secrets.GHA_SSH_PRIVATE_KEY }} - - name: Set domain - run: | - if [[ "${{ inputs.environment }}" == "staging" ]]; then - echo "DOMAIN=staging.govtool.byron.network" >> $GITHUB_ENV - elif [[ "${{ inputs.environment }}" == "beta" ]]; then - echo "DOMAIN=sanchogov.tools" >> $GITHUB_ENV - else - echo "DOMAIN=${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}" >> $GITHUB_ENV - fi - - - name: Destroy Cardano Node, DB sync and Postgres if required - if: ${{ inputs.resync_cardano_node_and_db }} + - name: Destroy Cardano Node, DB sync and Postgres database run: | make --debug=b destroy-cardano-node-and-dbsync - 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