From ef05946832a0d14d4f65a8a2ec1cb8a92f28a4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Wed, 19 Oct 2022 14:51:59 +0200 Subject: [PATCH] fix: scheduler release workflow --- .github/workflows/scheduler.release.yml | 136 ------------------------ .github/workflows/scheduler.yml | 39 +++++++ 2 files changed, 39 insertions(+), 136 deletions(-) delete mode 100644 .github/workflows/scheduler.release.yml create mode 100644 .github/workflows/scheduler.yml diff --git a/.github/workflows/scheduler.release.yml b/.github/workflows/scheduler.release.yml deleted file mode 100644 index 4a45b5d98..000000000 --- a/.github/workflows/scheduler.release.yml +++ /dev/null @@ -1,136 +0,0 @@ -name: Scheduler Server - -concurrency: - group: scheduler - cancel-in-progress: true - -on: - push: - tags: - - '*standardnotes/scheduler-server*' - workflow_dispatch: - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - run: yarn build - - run: yarn lint:scheduler - - run: yarn test:scheduler - - publish-aws-ecr: - needs: test - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - name: Build locally - run: yarn build - - 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: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: scheduler-worker - IMAGE_TAG: ${{ github.sha }} - 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:latest - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest - - publish-docker-hub: - needs: test - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - name: Build locally - run: yarn build - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build, tag, and push image to Docker Hub - 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:latest - docker push standardnotes/scheduler:latest - - deploy-worker: - needs: publish-aws-ecr - - runs-on: ubuntu-latest - - steps: - - 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 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: 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: scheduler-worker-prod - image: ${{ secrets.AWS_ECR_REGISTRY }}/scheduler-worker:${{ github.sha }} - - name: 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: scheduler-worker-prod - cluster: prod - wait-for-service-stability: true - - newrelic: - needs: [ deploy-worker ] - - runs-on: ubuntu-latest - - steps: - - name: Create New Relic deployment marker for Worker - uses: newrelic/deployment-marker-action@v1 - with: - accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} - apiKey: ${{ secrets.NEW_RELIC_API_KEY }} - applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_SCHEDULER_WORKER_PROD }} - revision: "${{ github.sha }}" - description: "Automated Deployment via Github Actions" - user: "${{ github.actor }}" diff --git a/.github/workflows/scheduler.yml b/.github/workflows/scheduler.yml new file mode 100644 index 000000000..8ca548c77 --- /dev/null +++ b/.github/workflows/scheduler.yml @@ -0,0 +1,39 @@ +name: Scheduler Server + +concurrency: + group: scheduler + cancel-in-progress: true + +on: + push: + tags: + - '*standardnotes/scheduler-server*' + workflow_dispatch: + +jobs: + call_server_application_workflow: + name: Server Application + uses: standardnotes/server/.github/workflows/server-application.yml@main + with: + service_name: scheduler + workspace_name: "@standardnotes/scheduler-server" + run_e2e_test_suite: false + deploy_web: false + package_path: packages/scheduler + secrets: inherit + + newrelic: + needs: call_server_application_workflow + + runs-on: ubuntu-latest + + steps: + - name: Create New Relic deployment marker for Worker + uses: newrelic/deployment-marker-action@v1 + with: + accountId: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} + apiKey: ${{ secrets.NEW_RELIC_API_KEY }} + applicationId: ${{ secrets.NEW_RELIC_APPLICATION_ID_SCHEDULER_WORKER_PROD }} + revision: "${{ github.sha }}" + description: "Automated Deployment via Github Actions" + user: "${{ github.actor }}"