From 2d7cee9d144bd1c7d7a12af9928299da5a8d698c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Wed, 19 Oct 2022 14:54:17 +0200 Subject: [PATCH] fix: syncing server release workflow --- .github/workflows/syncing-server.release.yml | 313 ------------------- .github/workflows/syncing-server.yml | 47 +++ 2 files changed, 47 insertions(+), 313 deletions(-) delete mode 100644 .github/workflows/syncing-server.release.yml create mode 100644 .github/workflows/syncing-server.yml diff --git a/.github/workflows/syncing-server.release.yml b/.github/workflows/syncing-server.release.yml deleted file mode 100644 index 5a39da0ce..000000000 --- a/.github/workflows/syncing-server.release.yml +++ /dev/null @@ -1,313 +0,0 @@ -name: Syncing Server - -concurrency: - group: syncing_server - cancel-in-progress: true - -on: - push: - tags: - - '*standardnotes/syncing-server*' - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Cache build - id: cache-build - uses: actions/cache@v3 - with: - path: packages/**/dist - key: ${{ runner.os }}-syncing-server-build-${{ github.sha }} - - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - - name: Build - run: yarn build:syncing-server - - lint: - runs-on: ubuntu-latest - - needs: build - - steps: - - uses: actions/checkout@v3 - - - name: Cache build - id: cache-build - uses: actions/cache@v3 - with: - path: packages/**/dist - key: ${{ runner.os }}-syncing-server-build-${{ github.sha }} - - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - - name: Build - if: steps.cache-build.outputs.cache-hit != 'true' - run: yarn build:syncing-server - - - name: Lint - run: yarn lint:syncing-server - - test: - runs-on: ubuntu-latest - - needs: build - - steps: - - uses: actions/checkout@v3 - - - name: Cache build - id: cache-build - uses: actions/cache@v3 - with: - path: packages/**/dist - key: ${{ runner.os }}-syncing-server-build-${{ github.sha }} - - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - - name: Build - if: steps.cache-build.outputs.cache-hit != 'true' - run: yarn build:syncing-server - - - name: Test - run: yarn test:syncing-server - - e2e: - runs-on: ubuntu-latest - - needs: build - - steps: - - uses: actions/checkout@v3 - - - name: Cache build - id: cache-build - uses: actions/cache@v3 - with: - path: packages/**/dist - key: ${{ runner.os }}-syncing-server-build-${{ github.sha }} - - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - - name: Build - if: steps.cache-build.outputs.cache-hit != 'true' - run: yarn build:syncing-server - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Publish Docker image for E2E testing - run: | - yarn docker build @standardnotes/syncing-server -t standardnotes/syncing-server-js:${{ github.sha }} - docker push standardnotes/syncing-server-js:${{ github.sha }} - - - name: Run E2E test suite - uses: convictional/trigger-workflow-and-wait@v1.6.3 - with: - owner: standardnotes - repo: e2e - github_token: ${{ secrets.CI_PAT_TOKEN }} - workflow_file_name: testing-with-stable-client.yml - wait_interval: 30 - client_payload: '{"syncing_server_js_image_tag": "${{ github.sha }}"}' - propagate_failure: true - trigger_workflow: true - wait_workflow: true - - publish-aws-ecr: - needs: [ test, lint, e2e ] - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Cache build - id: cache-build - uses: actions/cache@v3 - with: - path: packages/**/dist - key: ${{ runner.os }}-syncing-server-build-${{ github.sha }} - - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - - name: Build - if: steps.cache-build.outputs.cache-hit != 'true' - run: yarn build:syncing-server - - - 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: syncing-server-js - IMAGE_TAG: ${{ github.sha }} - run: | - yarn docker build @standardnotes/syncing-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, lint, e2e ] - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Cache build - id: cache-build - uses: actions/cache@v3 - with: - path: packages/**/dist - key: ${{ runner.os }}-syncing-server-build-${{ github.sha }} - - - name: Set up Node - uses: actions/setup-node@v3 - with: - registry-url: 'https://registry.npmjs.org' - node-version-file: '.nvmrc' - - - name: Build - if: steps.cache-build.outputs.cache-hit != 'true' - run: yarn build:syncing-server - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Publish Docker image as stable - run: | - yarn docker build @standardnotes/syncing-server -t standardnotes/syncing-server-js:latest - docker push standardnotes/syncing-server-js:latest - - deploy-web: - 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 syncing-server-js-prod --query taskDefinition > task-definition.json - - name: Fill in the new version in the Amazon ECS task definition - 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 - - 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: syncing-server-js-prod - image: ${{ secrets.AWS_ECR_REGISTRY }}/syncing-server-js:${{ 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: syncing-server-js-prod - cluster: prod - wait-for-service-stability: true - - 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 syncing-server-js-worker-prod --query taskDefinition > task-definition.json - - name: Fill in the new version in the Amazon ECS task definition - 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 - - 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: syncing-server-js-worker-prod - image: ${{ secrets.AWS_ECR_REGISTRY }}/syncing-server-js:${{ 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: syncing-server-js-worker-prod - cluster: prod - wait-for-service-stability: true - - newrelic: - needs: [ deploy-web, deploy-worker ] - - runs-on: ubuntu-latest - steps: - - name: Create New Relic deployment marker for Web - 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_SYNCING_SERVER_WEB_PROD }} - revision: "${{ github.sha }}" - description: "Automated Deployment via Github Actions" - user: "${{ github.actor }}" - - 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_SYNCING_SERVER_WORKER_PROD }} - revision: "${{ github.sha }}" - description: "Automated Deployment via Github Actions" - user: "${{ github.actor }}" diff --git a/.github/workflows/syncing-server.yml b/.github/workflows/syncing-server.yml new file mode 100644 index 000000000..cface5f9c --- /dev/null +++ b/.github/workflows/syncing-server.yml @@ -0,0 +1,47 @@ +name: Syncing Server + +concurrency: + group: syncing_server + cancel-in-progress: true + +on: + push: + tags: + - '*standardnotes/syncing-server*' + workflow_dispatch: + +jobs: + call_server_application_workflow: + name: Server Application + uses: standardnotes/server/.github/workflows/server-application.yml@main + with: + service_name: syncing-server-js + workspace_name: "@standardnotes/syncing-server" + run_e2e_test_suite: true + e2e_tag_parameter_name: syncing_server_js_image_tag + package_path: packages/syncing-server + secrets: inherit + + newrelic: + needs: call_server_application_workflow + + runs-on: ubuntu-latest + steps: + - name: Create New Relic deployment marker for Web + 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_SYNCING_SERVER_WEB_PROD }} + revision: "${{ github.sha }}" + description: "Automated Deployment via Github Actions" + user: "${{ github.actor }}" + - 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_SYNCING_SERVER_WORKER_PROD }} + revision: "${{ github.sha }}" + description: "Automated Deployment via Github Actions" + user: "${{ github.actor }}"