chore: improve deploy workflow for workspaces

This commit is contained in:
Karol Sójko
2022-10-14 12:11:43 +02:00
parent f0f3dad082
commit faacf92ba3
+116 -8
View File
@@ -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