From 46e8348ea28dc6074ddeee779663a043a9bab294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Wed, 15 Dec 2021 12:53:37 +0100 Subject: [PATCH] feat: add beta deployment on feature branches --- .github/workflows/beta.yml | 72 ++++++++++++++++++++++++++++++++++++++ .github/workflows/dev.yml | 10 +++--- .github/workflows/prod.yml | 10 +++--- 3 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/beta.yml diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml new file mode 100644 index 000000000..941941caf --- /dev/null +++ b/.github/workflows/beta.yml @@ -0,0 +1,72 @@ +name: Dev + +on: + push: + branches: [ feature/* ] + +jobs: + tsc: + name: Check types & lint + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Install dependencies + run: yarn install --pure-lockfile + - name: Typescript + run: yarn tsc + - name: ESLint + run: yarn lint --quiet + + deploy: + runs-on: ubuntu-latest + needs: tsc + + steps: + - uses: actions/checkout@v2 + - name: Copy robots.txt + run: cp public/robots.txt.development public/robots.txt + - name: Publish to Registry + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: standardnotes/web + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + tags: "beta,${{ github.sha }}" + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition app-beta-dev --query taskDefinition > task-definition.json + + - name: Fill in the new image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: app-beta-dev + image: "standardnotes/web:${{ github.sha }}" + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: app-beta-dev + cluster: dev + wait-for-service-stability: true + + notify_discord: + needs: deploy + + runs-on: ubuntu-latest + + steps: + - name: Run Discord Webhook + uses: johnnyhuy/actions-discord-git-webhook@main + with: + webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }} diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index b73771dc2..cb2af7d02 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -73,15 +73,13 @@ jobs: cluster: dev wait-for-service-stability: true - notify_slack: + notify_discord: needs: deploy runs-on: ubuntu-latest steps: - - name: Notify slack - uses: pullreminders/slack-action@master - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + - name: Run Discord Webhook + uses: johnnyhuy/actions-discord-git-webhook@main with: - args: '{ \"channel\": \"${{ secrets.SLACK_NOTIFICATION_CHANNEL }}\", \"blocks\": [{\"type\": \"section\", \"text\": {\"type\": \"mrkdwn\", \"text\": \"Successfully deployed \"}}, {\"type\": \"section\", \"text\": {\"type\": \"mrkdwn\", \"text\": \"Changes: \"}, \"accessory\": {\"type\": \"image\", \"image_url\": \"https://website-dev.standardnotes.com/assets/icon.png\", \"alt_text\": \"Standard Notes\"}}, { \"type\": \"section\", \"fields\": [{\"type\": \"mrkdwn\", \"text\": \"\"}]}]}' + webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }} diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index feac7cd51..8b01feb81 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -73,15 +73,13 @@ jobs: cluster: prod wait-for-service-stability: true - notify_slack: + notify_discord: needs: deploy runs-on: ubuntu-latest steps: - - name: Notify slack - uses: pullreminders/slack-action@master - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + - name: Run Discord Webhook + uses: johnnyhuy/actions-discord-git-webhook@main with: - args: '{ \"channel\": \"${{ secrets.SLACK_NOTIFICATION_CHANNEL }}\", \"blocks\": [{\"type\": \"section\", \"text\": {\"type\": \"mrkdwn\", \"text\": \"Successfully deployed \"}}, {\"type\": \"section\", \"text\": {\"type\": \"mrkdwn\", \"text\": \"Changes: \"}, \"accessory\": {\"type\": \"image\", \"image_url\": \"https://website-dev.standardnotes.com/assets/icon.png\", \"alt_text\": \"Standard Notes\"}}, { \"type\": \"section\", \"fields\": [{\"type\": \"mrkdwn\", \"text\": \"\"}]}]}' + webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}