From c40f1312cabdbdceea7da5d4541b4dd8f558f0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Mon, 17 Oct 2022 09:43:45 +0200 Subject: [PATCH] fix(syncing-server): github workflow --- .github/workflows/syncing-server.release.yml | 125 +++++++++++++++++-- 1 file changed, 116 insertions(+), 9 deletions(-) diff --git a/.github/workflows/syncing-server.release.yml b/.github/workflows/syncing-server.release.yml index 32aab1115..5a39da0ce 100644 --- a/.github/workflows/syncing-server.release.yml +++ b/.github/workflows/syncing-server.release.yml @@ -11,12 +11,19 @@ on: workflow_dispatch: jobs: - test: + 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: @@ -24,14 +31,89 @@ jobs: node-version-file: '.nvmrc' - name: Build - run: yarn 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: @@ -57,28 +139,41 @@ jobs: wait_workflow: true publish-aws-ecr: - needs: test + 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 locally - run: yarn build + + - 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: @@ -92,25 +187,37 @@ jobs: docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest publish-docker-hub: - needs: test + 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 locally - run: yarn build + + - 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: Build, tag, and push image to Docker Hub + + - 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