standardnotes-server/.github/workflows/common-docker-image.yml

96 lines
2.5 KiB
YAML
Raw Normal View History

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
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:
- 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'
- 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'
- name: Install dependencies
run: yarn install --immutable
- name: Build
if: steps.cache-build.outputs.cache-hit != 'true'
2023-09-19 06:36:02 +00:00
run: yarn build
2022-10-20 07:59:52 +00:00
- name: Login to Docker Hub
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
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
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
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