From ea5d85aefefe012a060732224940c4d14cf7f131 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 15:39:56 -0300 Subject: [PATCH 01/12] ci: configure automated deploy --- .github/workflows/deploy.yml | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..136083bc --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,40 @@ +name: deploy + +on: + push: + branches: [dev, master] + tags: ['v*.*.*'] + +env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: 'eu-central-1' + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Push Dev Image + if: github.ref == 'refs/heads/dev' + run: | + make build-and-push-docker + - name: Push Testnet Image + if: github.ref == 'refs/heads/master' + run: | + commit=`git rev-parse HEAD`; + timestamp=`date +%s`; + export DOCKER_IMAGE_TAG="master-$commit-$timestamp"; + + make build-and-push-docker + - name: Push Mainnet Image + if: startsWith(github.ref, 'refs/tags/v') + run: | + export DOCKER_IMAGE_TAG=${GITHUB_REF#refs/*/} + make build-and-push-docker + # TODO Send message to Slack + - name: Clean + run: | + rm /home/runner/.docker/config.json From d41c23b01b0d1db09645a608994f3c73eea1e894 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 17:55:35 -0300 Subject: [PATCH 02/12] send message to Slack --- .github/workflows/deploy.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 136083bc..a7d107e7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: deploy on: push: - branches: [dev, master] + branches: [dev, master, ci/deploy] tags: ['v*.*.*'] env: @@ -35,6 +35,15 @@ jobs: export DOCKER_IMAGE_TAG=${GITHUB_REF#refs/*/} make build-and-push-docker # TODO Send message to Slack + - name: Slack Notification + uses: rtCamp/action-slack-notify@28e8b353eabda5998a2e1203aed33c5999944779 + env: + SLACK_CHANNEL: deploys + SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff' + SLACK_MESSAGE: 'Check if there is a commit here to make sure the deploy worked: https://github.com/HathorNetwork/ops-tools/commits/master' + SLACK_TITLE: 'WalletServiceDaemon - Deploying new image :rocket:' + SLACK_USERNAME: HathorSlack + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - name: Clean run: | rm /home/runner/.docker/config.json From d7deac7976e6055f3c64cdadef61fc6b6c56e4d6 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 18:04:44 -0300 Subject: [PATCH 03/12] trigger build From d2b0b3fe5677a6bfa764d4fb5b72e10aba887d54 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 18:08:13 -0300 Subject: [PATCH 04/12] trigger build From 995bb83cf93ba992c3dac1f044665c18794e1df5 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 18:17:18 -0300 Subject: [PATCH 05/12] trigger build From fdc15b21fc53009ebed17a8c1365e2f78fcb812a Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 18:33:23 -0300 Subject: [PATCH 06/12] trigger build From 44aef2e01e6cd4d4ec5f1038cdc15936694979e3 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 18:34:07 -0300 Subject: [PATCH 07/12] trigger build From be484823bbc9d856c937eff058151a724f666466 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 18:34:50 -0300 Subject: [PATCH 08/12] trigger build From 680c5ac98b6d6cc7c81f88f4a83087b37efb8ea9 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 18:36:36 -0300 Subject: [PATCH 09/12] trigger build From d0e856ff36942814f984321f8dbd531ee80f4232 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 19:02:18 -0300 Subject: [PATCH 10/12] improve message --- .github/workflows/deploy.yml | 12 ++++++++++-- .github/workflows/main.yml | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a7d107e7..49125495 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,6 +21,8 @@ jobs: if: github.ref == 'refs/heads/dev' run: | make build-and-push-docker + + echo "environment=dev-testnet" >> $GITHUB_ENV - name: Push Testnet Image if: github.ref == 'refs/heads/master' run: | @@ -29,21 +31,27 @@ jobs: export DOCKER_IMAGE_TAG="master-$commit-$timestamp"; make build-and-push-docker + + echo "environment=testnet" >> $GITHUB_ENV - name: Push Mainnet Image if: startsWith(github.ref, 'refs/tags/v') run: | export DOCKER_IMAGE_TAG=${GITHUB_REF#refs/*/} make build-and-push-docker + + echo "environment=mainnet" >> $GITHUB_ENV # TODO Send message to Slack - name: Slack Notification uses: rtCamp/action-slack-notify@28e8b353eabda5998a2e1203aed33c5999944779 env: SLACK_CHANNEL: deploys SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff' - SLACK_MESSAGE: 'Check if there is a commit here to make sure the deploy worked: https://github.com/HathorNetwork/ops-tools/commits/master' - SLACK_TITLE: 'WalletServiceDaemon - Deploying new image :rocket:' + SLACK_MESSAGE: 'Make sure the image is correctly deployed by checking if a new commit by fluxcdbot was made: https://github.com/HathorNetwork/ops-tools/commits/master' + SLACK_TITLE: 'WalletServiceDaemon - new ${{ env.environment }} Docker image pushed :rocket:' SLACK_USERNAME: HathorSlack SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_FOOTER: '' + MSG_MINIMAL: actions url - name: Clean run: | rm /home/runner/.docker/config.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 535e4b7c..d44241ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: node-version: ${{ matrix.node }} - name: Install deps and build (with cache) - uses: bahmutov/npm-install@v1 + uses: bahmutov/npm-install@c67aaab58a864ea2873950cde9c1c9379f9f711a - name: Lint run: yarn lint From 79e7746e29c1e6f9d9e98638e5e64870cda947bd Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 19:04:03 -0300 Subject: [PATCH 11/12] send message only in case of deploy --- .github/workflows/deploy.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 49125495..bc97fc90 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,7 +22,7 @@ jobs: run: | make build-and-push-docker - echo "environment=dev-testnet" >> $GITHUB_ENV + echo "deployed_environment=dev-testnet" >> $GITHUB_ENV - name: Push Testnet Image if: github.ref == 'refs/heads/master' run: | @@ -32,22 +32,23 @@ jobs: make build-and-push-docker - echo "environment=testnet" >> $GITHUB_ENV + echo "deployed_environment=testnet" >> $GITHUB_ENV - name: Push Mainnet Image if: startsWith(github.ref, 'refs/tags/v') run: | export DOCKER_IMAGE_TAG=${GITHUB_REF#refs/*/} make build-and-push-docker - echo "environment=mainnet" >> $GITHUB_ENV + echo "deployed_environment=mainnet" >> $GITHUB_ENV # TODO Send message to Slack - name: Slack Notification + if: env.deployed_environment uses: rtCamp/action-slack-notify@28e8b353eabda5998a2e1203aed33c5999944779 env: SLACK_CHANNEL: deploys SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff' SLACK_MESSAGE: 'Make sure the image is correctly deployed by checking if a new commit by fluxcdbot was made: https://github.com/HathorNetwork/ops-tools/commits/master' - SLACK_TITLE: 'WalletServiceDaemon - new ${{ env.environment }} Docker image pushed :rocket:' + SLACK_TITLE: 'WalletServiceDaemon - new ${{ env.deployed_environment }} Docker image pushed :rocket:' SLACK_USERNAME: HathorSlack SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} SLACK_FOOTER: '' From b0c403cc84abd2f0c96ce2c7a0d576a893beafc3 Mon Sep 17 00:00:00 2001 From: Luis Helder Date: Tue, 31 Aug 2021 19:05:46 -0300 Subject: [PATCH 12/12] Remove TODO --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bc97fc90..c29712d6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,14 +40,13 @@ jobs: make build-and-push-docker echo "deployed_environment=mainnet" >> $GITHUB_ENV - # TODO Send message to Slack - name: Slack Notification if: env.deployed_environment uses: rtCamp/action-slack-notify@28e8b353eabda5998a2e1203aed33c5999944779 env: SLACK_CHANNEL: deploys SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff' - SLACK_MESSAGE: 'Make sure the image is correctly deployed by checking if a new commit by fluxcdbot was made: https://github.com/HathorNetwork/ops-tools/commits/master' + SLACK_MESSAGE: 'Make sure the image is correctly deployed by checking if a new commit by fluxcdbot was made in: https://github.com/HathorNetwork/ops-tools/commits/master' SLACK_TITLE: 'WalletServiceDaemon - new ${{ env.deployed_environment }} Docker image pushed :rocket:' SLACK_USERNAME: HathorSlack SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}