From 100eef2cb84dec4ac6cdf301e1d53b74b5419bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Thu, 23 Jun 2022 18:27:37 +0200 Subject: [PATCH] feat: prepare files server and scheduler for one branch only development --- ...iles.release.dev.yml => files.release.yml} | 75 ++++++++++++++----- ....release.dev.yml => scheduler.release.yml} | 43 ++++++++--- 2 files changed, 88 insertions(+), 30 deletions(-) rename .github/workflows/{files.release.dev.yml => files.release.yml} (63%) rename .github/workflows/{scheduler.release.dev.yml => scheduler.release.yml} (70%) diff --git a/.github/workflows/files.release.dev.yml b/.github/workflows/files.release.yml similarity index 63% rename from .github/workflows/files.release.dev.yml rename to .github/workflows/files.release.yml index 615fc1dec..39a6a4a71 100644 --- a/.github/workflows/files.release.dev.yml +++ b/.github/workflows/files.release.yml @@ -1,14 +1,13 @@ -name: Files Server Dev +name: Files Server concurrency: - group: files_dev_environment + group: files cancel-in-progress: true on: push: tags: - - '@standardnotes/files-server@[0-9]*.[0-9]*.[0-9]*-alpha.[0-9]*' - - '@standardnotes/files-server@[0-9]*.[0-9]*.[0-9]*-beta.[0-9]*' + - '*standardnotes/files-server*' workflow_dispatch: jobs: @@ -50,8 +49,8 @@ jobs: run: | yarn docker build @standardnotes/files-server -t $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 push $ECR_REGISTRY/$ECR_REPOSITORY:dev + docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest + docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest publish-docker-hub: needs: test @@ -71,8 +70,8 @@ jobs: run: | yarn docker build @standardnotes/files-server -t standardnotes/files:${{ github.sha }} docker push standardnotes/files:${{ github.sha }} - docker tag standardnotes/files:${{ github.sha }} standardnotes/files:dev - docker push standardnotes/files:dev + docker tag standardnotes/files:${{ github.sha }} standardnotes/files:latest + docker push standardnotes/files:latest deploy-web: needs: publish-aws-ecr @@ -86,26 +85,46 @@ jobs: 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 + - name: DEV - Download task definition run: | aws ecs describe-task-definition --task-definition files-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: | 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: 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 uses: aws-actions/amazon-ecs-render-task-definition@v1 with: task-definition: task-definition.json container-name: files-dev image: ${{ secrets.AWS_ECR_REGISTRY }}/files:${{ github.sha }} - - name: Deploy Amazon ECS task definition + - name: DEV - Deploy Amazon ECS task definition uses: aws-actions/amazon-ecs-deploy-task-definition@v1 with: task-definition: ${{ steps.task-def.outputs.task-definition }} service: files-dev cluster: dev wait-for-service-stability: true + - name: PROD - Download task definition + run: | + aws ecs describe-task-definition --task-definition files-prod --query taskDefinition > task-definition.json + - name: PROD - Fill in the new version in the Amazon ECS task definition + 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 + - name: PROD - 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: files-prod + image: ${{ secrets.AWS_ECR_REGISTRY }}/files:${{ github.sha }} + - name: PROD - Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: files-prod + cluster: prod + wait-for-service-stability: true deploy-worker: needs: publish-aws-ecr @@ -119,26 +138,46 @@ jobs: 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 + - name: DEV - Download task definition run: | aws ecs describe-task-definition --task-definition files-worker-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: | 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: 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 uses: aws-actions/amazon-ecs-render-task-definition@v1 with: task-definition: task-definition.json container-name: files-worker-dev image: ${{ secrets.AWS_ECR_REGISTRY }}/files:${{ github.sha }} - - name: Deploy Amazon ECS task definition + - name: DEV - Deploy Amazon ECS task definition uses: aws-actions/amazon-ecs-deploy-task-definition@v1 with: task-definition: ${{ steps.task-def.outputs.task-definition }} service: files-worker-dev cluster: dev wait-for-service-stability: true + - name: PROD - Download task definition + run: | + aws ecs describe-task-definition --task-definition files-worker-prod --query taskDefinition > task-definition.json + - name: PROD - Fill in the new version in the Amazon ECS task definition + 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 + - name: PROD - 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: files-worker-prod + image: ${{ secrets.AWS_ECR_REGISTRY }}/files:${{ github.sha }} + - name: PROD - Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: files-worker-prod + cluster: prod + wait-for-service-stability: true newrelic: needs: [ deploy-web, deploy-worker ] @@ -150,7 +189,7 @@ jobs: with: accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} apiKey: ${{ secrets.NEW_RELIC_API_KEY }} - applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_FILES_WEB_DEV }} + applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_FILES_WEB_PROD }} revision: "${{ github.sha }}" description: "Automated Deployment via Github Actions" user: "${{ github.actor }}" @@ -159,7 +198,7 @@ jobs: with: accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} apiKey: ${{ secrets.NEW_RELIC_API_KEY }} - applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_FILES_WORKER_DEV }} + applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_FILES_WORKER_PROD }} revision: "${{ github.sha }}" description: "Automated Deployment via Github Actions" user: "${{ github.actor }}" diff --git a/.github/workflows/scheduler.release.dev.yml b/.github/workflows/scheduler.release.yml similarity index 70% rename from .github/workflows/scheduler.release.dev.yml rename to .github/workflows/scheduler.release.yml index 6cee0e788..eee79c323 100644 --- a/.github/workflows/scheduler.release.dev.yml +++ b/.github/workflows/scheduler.release.yml @@ -1,14 +1,13 @@ -name: Scheduler Server Dev +name: Scheduler Server concurrency: - group: scheduler_dev_environment + group: scheduler cancel-in-progress: true on: push: tags: - - '@standardnotes/scheduler-server@[0-9]*.[0-9]*.[0-9]*-alpha.[0-9]*' - - '@standardnotes/scheduler-server@[0-9]*.[0-9]*.[0-9]*-beta.[0-9]*' + - '*standardnotes/scheduler-server*' workflow_dispatch: jobs: @@ -50,8 +49,8 @@ jobs: run: | yarn docker build @standardnotes/scheduler-server -t $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 push $ECR_REGISTRY/$ECR_REPOSITORY:dev + docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest + docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest publish-docker-hub: needs: test @@ -71,8 +70,8 @@ jobs: run: | yarn docker build @standardnotes/scheduler-server -t standardnotes/scheduler:${{ github.sha }} docker push standardnotes/scheduler:${{ github.sha }} - docker tag standardnotes/scheduler:${{ github.sha }} standardnotes/scheduler:dev - docker push standardnotes/scheduler:dev + docker tag standardnotes/scheduler:${{ github.sha }} standardnotes/scheduler:latest + docker push standardnotes/scheduler:latest deploy-worker: needs: publish-aws-ecr @@ -86,26 +85,46 @@ jobs: 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 + - name: DEV - Download task definition run: | aws ecs describe-task-definition --task-definition scheduler-worker-dev --query taskDefinition > task-definition.json - name: Fill in the new version in the Amazon ECS task definition 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 - - 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 uses: aws-actions/amazon-ecs-render-task-definition@v1 with: task-definition: task-definition.json container-name: scheduler-worker-dev image: ${{ secrets.AWS_ECR_REGISTRY }}/scheduler-worker:${{ github.sha }} - - name: Deploy Amazon ECS task definition + - name: DEV - Deploy Amazon ECS task definition uses: aws-actions/amazon-ecs-deploy-task-definition@v1 with: task-definition: ${{ steps.task-def.outputs.task-definition }} service: scheduler-worker-dev cluster: dev wait-for-service-stability: true + - name: PROD - Download task definition + run: | + aws ecs describe-task-definition --task-definition scheduler-worker-prod --query taskDefinition > task-definition.json + - name: Fill in the new version in the Amazon ECS task definition + 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 + - name: PROD - 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: scheduler-worker-prod + image: ${{ secrets.AWS_ECR_REGISTRY }}/scheduler-worker:${{ github.sha }} + - name: PROD - Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: scheduler-worker-prod + cluster: prod + wait-for-service-stability: true newrelic: needs: [ deploy-worker ] @@ -118,7 +137,7 @@ jobs: with: accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} apiKey: ${{ secrets.NEW_RELIC_API_KEY }} - applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_SCHEDULER_WORKER_DEV }} + applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_SCHEDULER_WORKER_PROD }} revision: "${{ github.sha }}" description: "Automated Deployment via Github Actions" user: "${{ github.actor }}"