mirror of
https://github.com/standardnotes/server
synced 2026-09-12 06:45:24 -04:00
fix: bundling and publishing to separate registries
This commit is contained in:
@@ -34,6 +34,9 @@ on:
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
required: true
|
||||
|
||||
env:
|
||||
TEMP_DIR: $(mktemp -d -t "${{ inputs.service_name }}-${{ github.sha }}-XXXXXXX")
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -45,7 +48,9 @@ jobs:
|
||||
id: cache-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: packages/**/dist
|
||||
path: |
|
||||
packages/**/dist
|
||||
$TEMP_DIR
|
||||
key: ${{ runner.os }}-${{ inputs.service_name }}-build-${{ github.sha }}
|
||||
|
||||
- name: Set up Node
|
||||
@@ -57,6 +62,9 @@ jobs:
|
||||
- name: Build
|
||||
run: yarn build ${{ inputs.package_path }}
|
||||
|
||||
- name: Bundle
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory $TEMP_DIR
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -142,11 +150,8 @@ jobs:
|
||||
run: yarn build ${{ inputs.package_path }}
|
||||
|
||||
- name: Bundle
|
||||
id: bundle
|
||||
run: |
|
||||
TEMP_DIR=$(mktemp -d -t "${{ inputs.service_name }}-${{ github.sha }}-XXXXXXX")
|
||||
echo "::set-output name=dir::$TEMP_DIR"
|
||||
yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory $TEMP_DIR
|
||||
if: steps.cache-build.outputs.cache-hit != 'true'
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory $TEMP_DIR
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
@@ -167,8 +172,8 @@ jobs:
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ${{ steps.bundle.outputs.dir }}
|
||||
file: ${{ steps.bundle.outputs.dir }}/${{ inputs.package_path }}/Dockerfile
|
||||
context: $TEMP_DIR
|
||||
file: $TEMP_DIR/${{ inputs.package_path }}/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: standardnotes/${{ inputs.service_name }}:${{ github.sha }}
|
||||
@@ -186,7 +191,7 @@ jobs:
|
||||
trigger_workflow: true
|
||||
wait_workflow: true
|
||||
|
||||
publish:
|
||||
publish-aws-ecr:
|
||||
needs: [ test, lint, e2e ]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
@@ -212,11 +217,8 @@ jobs:
|
||||
run: yarn build ${{ inputs.package_path }}
|
||||
|
||||
- name: Bundle
|
||||
id: bundle
|
||||
run: |
|
||||
TEMP_DIR=$(mktemp -d -t "${{ inputs.service_name }}-${{ github.sha }}-XXXXXXX")
|
||||
echo "::set-output name=dir::$TEMP_DIR"
|
||||
yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory $TEMP_DIR
|
||||
if: steps.cache-build.outputs.cache-hit != 'true'
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory $TEMP_DIR
|
||||
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
@@ -229,6 +231,56 @@ jobs:
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@v1
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@master
|
||||
with:
|
||||
platforms: all
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@master
|
||||
|
||||
- name: Publish Docker image
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: $TEMP_DIR
|
||||
file: $TEMP_DIR/${{ inputs.package_path }}/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
${{ steps.login-ecr.outputs.registry }}/${{ inputs.service_name }}:${{ github.sha }}
|
||||
${{ steps.login-ecr.outputs.registry }}/${{ inputs.service_name }}: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 }}-${{ inputs.service_name }}-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 ${{ inputs.package_path }}
|
||||
|
||||
- name: Bundle
|
||||
if: steps.cache-build.outputs.cache-hit != 'true'
|
||||
run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory $TEMP_DIR
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
@@ -248,17 +300,15 @@ jobs:
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ${{ steps.bundle.outputs.dir }}
|
||||
file: ${{ steps.bundle.outputs.dir }}/${{ inputs.package_path }}/Dockerfile
|
||||
context: $TEMP_DIR
|
||||
file: $TEMP_DIR/${{ inputs.package_path }}/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
standardnotes/${{ inputs.service_name }}:latest
|
||||
${{ steps.login-ecr.outputs.registry }}/${{ inputs.service_name }}:${{ github.sha }}
|
||||
${{ steps.login-ecr.outputs.registry }}/${{ inputs.service_name }}:latest
|
||||
|
||||
deploy-web:
|
||||
needs: publish
|
||||
needs: [ publish-aws-ecr, publish-docker-hub ]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -296,7 +346,7 @@ jobs:
|
||||
wait-for-service-stability: true
|
||||
|
||||
deploy-worker:
|
||||
needs: publish
|
||||
needs: [ publish-aws-ecr, publish-docker-hub ]
|
||||
|
||||
if: ${{ inputs.deploy_worker }} == true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user