From faacf92ba37bcc5747345e50145a7c5dcac5fca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Fri, 14 Oct 2022 12:11:38 +0200 Subject: [PATCH] chore: improve deploy workflow for workspaces --- .github/workflows/workspace.release.yml | 124 ++++++++++++++++++++++-- 1 file changed, 116 insertions(+), 8 deletions(-) diff --git a/.github/workflows/workspace.release.yml b/.github/workflows/workspace.release.yml index 88c1072a6..3dfd3044e 100644 --- a/.github/workflows/workspace.release.yml +++ b/.github/workflows/workspace.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/workspace/dist + key: ${{ runner.os }}-workspace-build + - name: Set up Node uses: actions/setup-node@v3 with: @@ -24,14 +31,90 @@ jobs: node-version-file: '.nvmrc' - name: Build - run: yarn build + if: steps.cache-build.outputs.cache-hit != 'true' + run: yarn build:workspace + + 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/workspace/dist + key: ${{ runner.os }}-workspace-build + + - 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:workspace - name: Lint run: yarn lint:workspace + 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/workspace/dist + key: ${{ runner.os }}-workspace-build + + - 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:workspace + - name: Test run: yarn test:workspace + 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/workspace/dist + key: ${{ runner.os }}-workspace-build + + - 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:workspace + - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -57,28 +140,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/workspace/dist + key: ${{ runner.os }}-workspace-build + - 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:workspace + - 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,24 +188,36 @@ 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/workspace/dist + key: ${{ runner.os }}-workspace-build + - 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:workspace + - 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/workspace-server -t standardnotes/workspace:latest