2022-10-20 08:07:57 +00:00
|
|
|
name: Reusable Publish Docker Image Workflow
|
2022-10-20 07:59:52 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
service_name:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
package_path:
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-09-18 12:34:26 +00:00
|
|
|
workspace_name:
|
|
|
|
required: true
|
|
|
|
type: string
|
2022-10-20 07:59:52 +00:00
|
|
|
secrets:
|
|
|
|
DOCKER_USERNAME:
|
|
|
|
required: true
|
|
|
|
DOCKER_PASSWORD:
|
|
|
|
required: true
|
|
|
|
AWS_ACCESS_KEY_ID:
|
|
|
|
required: true
|
|
|
|
AWS_SECRET_ACCESS_KEY:
|
|
|
|
required: true
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
publish:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2023-10-17 12:02:56 +00:00
|
|
|
- uses: actions/checkout@v4
|
2022-10-20 07:59:52 +00:00
|
|
|
|
2023-05-08 11:24:52 +00:00
|
|
|
- uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: '3.11'
|
|
|
|
|
2023-09-18 12:34:26 +00:00
|
|
|
- name: Cache build
|
|
|
|
id: cache-build
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
packages/**/dist
|
|
|
|
key: ${{ runner.os }}-${{ inputs.service_name }}-build-${{ github.sha }}
|
|
|
|
|
2022-10-20 07:59:52 +00:00
|
|
|
- name: Set up Node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
node-version-file: '.nvmrc'
|
|
|
|
|
2023-05-08 11:00:16 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: yarn install --immutable
|
|
|
|
|
2023-09-18 12:34:26 +00:00
|
|
|
- name: Build
|
|
|
|
if: steps.cache-build.outputs.cache-hit != 'true'
|
2023-09-19 06:36:02 +00:00
|
|
|
run: yarn build
|
2023-09-18 12:34:26 +00:00
|
|
|
|
2022-10-20 07:59:52 +00:00
|
|
|
- name: Login to Docker Hub
|
2023-11-01 12:33:03 +00:00
|
|
|
uses: docker/login-action@v3
|
2022-10-20 07:59:52 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
|
|
|
- name: Configure AWS credentials
|
2023-09-01 14:14:51 +00:00
|
|
|
uses: aws-actions/configure-aws-credentials@v3
|
2022-10-20 07:59:52 +00:00
|
|
|
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
|
2023-11-01 12:31:49 +00:00
|
|
|
uses: aws-actions/amazon-ecr-login@v2
|
2022-10-20 07:59:52 +00:00
|
|
|
|
|
|
|
- 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
|
2023-09-04 06:24:39 +00:00
|
|
|
uses: docker/build-push-action@v4
|
2022-10-20 07:59:52 +00:00
|
|
|
with:
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2023-09-18 12:18:17 +00:00
|
|
|
context: .
|
|
|
|
file: ${{ inputs.package_path }}/Dockerfile
|
2022-10-20 07:59:52 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
push: true
|
|
|
|
tags: |
|
|
|
|
standardnotes/${{ inputs.service_name }}:latest
|
|
|
|
standardnotes/${{ inputs.service_name }}:${{ github.sha }}
|
|
|
|
${{ steps.login-ecr.outputs.registry }}/${{ inputs.service_name }}:${{ github.sha }}
|
|
|
|
${{ steps.login-ecr.outputs.registry }}/${{ inputs.service_name }}:latest
|