feat: prepare api-gateway for one branch only development

This commit is contained in:
Karol Sójko 2022-06-23 18:34:03 +02:00
parent 100eef2cb8
commit 163b7ff2d8
No known key found for this signature in database
GPG key ID: A50543BF560BDEB0
4 changed files with 54 additions and 35 deletions

View file

@ -1,14 +1,13 @@
name: Api Gateway Dev name: Api Gateway
concurrency: concurrency:
group: api_gateway_dev_environment group: api_gateway
cancel-in-progress: true cancel-in-progress: true
on: on:
push: push:
tags: tags:
- '@standardnotes/api-gateway@[0-9]*.[0-9]*.[0-9]*-alpha.[0-9]*' - '*standardnotes/api-gateway*'
- '@standardnotes/api-gateway@[0-9]*.[0-9]*.[0-9]*-beta.[0-9]*'
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@ -49,8 +48,8 @@ jobs:
run: | run: |
yarn docker build @standardnotes/api-gateway -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG yarn docker build @standardnotes/api-gateway -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:dev docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:dev docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
publish-docker-hub: publish-docker-hub:
needs: test needs: test
@ -70,8 +69,8 @@ jobs:
run: | run: |
yarn docker build @standardnotes/api-gateway -t standardnotes/api-gateway:${{ github.sha }} yarn docker build @standardnotes/api-gateway -t standardnotes/api-gateway:${{ github.sha }}
docker push standardnotes/api-gateway:${{ github.sha }} docker push standardnotes/api-gateway:${{ github.sha }}
docker tag standardnotes/api-gateway:${{ github.sha }} standardnotes/api-gateway:dev docker tag standardnotes/api-gateway:${{ github.sha }} standardnotes/api-gateway:latest
docker push standardnotes/api-gateway:dev docker push standardnotes/api-gateway:latest
deploy-web: deploy-web:
needs: publish-aws-ecr needs: publish-aws-ecr
@ -85,26 +84,46 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1 aws-region: us-east-1
- name: Download task definition - name: DEV - Download task definition
run: | run: |
aws ecs describe-task-definition --task-definition api-gateway-dev --query taskDefinition > task-definition.json aws ecs describe-task-definition --task-definition api-gateway-dev --query taskDefinition > task-definition.json
- name: Fill in the new version in the Amazon ECS task definition - name: DEV - Fill in the new version in the Amazon ECS task definition
run: | run: |
jq '(.containerDefinitions[] | select(.name=="api-gateway-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="api-gateway-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition - name: DEV - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-dev
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
container-name: api-gateway-dev container-name: api-gateway-dev
image: ${{ secrets.AWS_ECR_REGISTRY }}/api-gateway:${{ github.sha }} image: ${{ secrets.AWS_ECR_REGISTRY }}/api-gateway:${{ github.sha }}
- name: Deploy Amazon ECS task definition - name: DEV - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-dev.outputs.task-definition }}
service: api-gateway-dev service: api-gateway-dev
cluster: dev cluster: dev
wait-for-service-stability: true wait-for-service-stability: true
- name: PROD - Download task definition
run: |
aws ecs describe-task-definition --task-definition api-gateway-prod --query taskDefinition > task-definition.json
- name: PROD - Fill in the new version in the Amazon ECS task definition
run: |
jq '(.containerDefinitions[] | select(.name=="api-gateway-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: PROD - Fill in the new image ID in the Amazon ECS task definition
id: task-def-prod
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: api-gateway-prod
image: ${{ secrets.AWS_ECR_REGISTRY }}/api-gateway:${{ github.sha }}
- name: PROD - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def-prod.outputs.task-definition }}
service: api-gateway-prod
cluster: prod
wait-for-service-stability: true
newrelic: newrelic:
needs: deploy-web needs: deploy-web
@ -116,7 +135,7 @@ jobs:
with: with:
accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
apiKey: ${{ secrets.NEW_RELIC_API_KEY }} apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_API_GATEWAY_WEB_DEV }} applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_API_GATEWAY_WEB_PROD }}
revision: "${{ github.sha }}" revision: "${{ github.sha }}"
description: "Automated Deployment via Github Actions" description: "Automated Deployment via Github Actions"
user: "${{ github.actor }}" user: "${{ github.actor }}"

View file

@ -92,7 +92,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="files-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="files-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: DEV - Fill in the new image ID in the Amazon ECS task definition - name: DEV - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-dev
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -101,7 +101,7 @@ jobs:
- name: DEV - Deploy Amazon ECS task definition - name: DEV - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-dev.outputs.task-definition }}
service: files-dev service: files-dev
cluster: dev cluster: dev
wait-for-service-stability: true wait-for-service-stability: true
@ -112,7 +112,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="files-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="files-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: PROD - Fill in the new image ID in the Amazon ECS task definition - name: PROD - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-prod
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -121,7 +121,7 @@ jobs:
- name: PROD - Deploy Amazon ECS task definition - name: PROD - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-prod.outputs.task-definition }}
service: files-prod service: files-prod
cluster: prod cluster: prod
wait-for-service-stability: true wait-for-service-stability: true
@ -145,7 +145,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="files-worker-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="files-worker-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: DEV - Fill in the new image ID in the Amazon ECS task definition - name: DEV - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-dev
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -154,7 +154,7 @@ jobs:
- name: DEV - Deploy Amazon ECS task definition - name: DEV - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-dev.outputs.task-definition }}
service: files-worker-dev service: files-worker-dev
cluster: dev cluster: dev
wait-for-service-stability: true wait-for-service-stability: true
@ -165,7 +165,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="files-worker-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="files-worker-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: PROD - Fill in the new image ID in the Amazon ECS task definition - name: PROD - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-prod
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -174,7 +174,7 @@ jobs:
- name: PROD - Deploy Amazon ECS task definition - name: PROD - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-prod.outputs.task-definition }}
service: files-worker-prod service: files-worker-prod
cluster: prod cluster: prod
wait-for-service-stability: true wait-for-service-stability: true

View file

@ -92,7 +92,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="scheduler-worker-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="scheduler-worker-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: DEV - Fill in the new image ID in the Amazon ECS task definition - name: DEV - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-dev
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -101,7 +101,7 @@ jobs:
- name: DEV - Deploy Amazon ECS task definition - name: DEV - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-dev.outputs.task-definition }}
service: scheduler-worker-dev service: scheduler-worker-dev
cluster: dev cluster: dev
wait-for-service-stability: true wait-for-service-stability: true
@ -112,7 +112,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="scheduler-worker-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="scheduler-worker-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: PROD - Fill in the new image ID in the Amazon ECS task definition - name: PROD - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-prod
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -121,7 +121,7 @@ jobs:
- name: PROD - Deploy Amazon ECS task definition - name: PROD - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-prod.outputs.task-definition }}
service: scheduler-worker-prod service: scheduler-worker-prod
cluster: prod cluster: prod
wait-for-service-stability: true wait-for-service-stability: true

View file

@ -93,7 +93,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="syncing-server-js-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="syncing-server-js-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: DEV - Fill in the new image ID in the Amazon ECS task definition - name: DEV - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-dev
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -102,7 +102,7 @@ jobs:
- name: DEV - Deploy Amazon ECS task definition - name: DEV - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-dev.outputs.task-definition }}
service: syncing-server-js-dev service: syncing-server-js-dev
cluster: dev cluster: dev
wait-for-service-stability: true wait-for-service-stability: true
@ -113,7 +113,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="syncing-server-js-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="syncing-server-js-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: PROD - Fill in the new image ID in the Amazon ECS task definition - name: PROD - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-prod
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -122,7 +122,7 @@ jobs:
- name: PROD - Deploy Amazon ECS task definition - name: PROD - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-prod.outputs.task-definition }}
service: syncing-server-js-prod service: syncing-server-js-prod
cluster: prod cluster: prod
wait-for-service-stability: true wait-for-service-stability: true
@ -146,7 +146,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="syncing-server-js-worker-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="syncing-server-js-worker-dev") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: DEV - Fill in the new image ID in the Amazon ECS task definition - name: DEV - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-dev
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -155,7 +155,7 @@ jobs:
- name: DEV - Deploy Amazon ECS task definition - name: DEV - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-dev.outputs.task-definition }}
service: syncing-server-js-worker-dev service: syncing-server-js-worker-dev
cluster: dev cluster: dev
wait-for-service-stability: true wait-for-service-stability: true
@ -166,7 +166,7 @@ jobs:
run: | run: |
jq '(.containerDefinitions[] | select(.name=="syncing-server-js-worker-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json jq '(.containerDefinitions[] | select(.name=="syncing-server-js-worker-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: PROD - Fill in the new image ID in the Amazon ECS task definition - name: PROD - Fill in the new image ID in the Amazon ECS task definition
id: task-def id: task-def-prod
uses: aws-actions/amazon-ecs-render-task-definition@v1 uses: aws-actions/amazon-ecs-render-task-definition@v1
with: with:
task-definition: task-definition.json task-definition: task-definition.json
@ -175,7 +175,7 @@ jobs:
- name: PROD - Deploy Amazon ECS task definition - name: PROD - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with: with:
task-definition: ${{ steps.task-def.outputs.task-definition }} task-definition: ${{ steps.task-def-prod.outputs.task-definition }}
service: syncing-server-js-worker-prod service: syncing-server-js-worker-prod
cluster: prod cluster: prod
wait-for-service-stability: true wait-for-service-stability: true