Skip to content

Digital Ocean deploy tweaks (#1239) #175

Digital Ocean deploy tweaks (#1239)

Digital Ocean deploy tweaks (#1239) #175

name: Publish Conductor API Container to GHCR
on:
push:
branches:
- main
release:
types: [published]
workflow_dispatch:
# Defines two custom environment variables for the workflow. These are
# used for the Container registry domain, and a name for the Docker
# image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{github.repository_owner}}/faims3-api
jobs:
build-and-push:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Uses the `docker/login-action` action to log in to the Container registry
# using the account and password that will publish the packages.
# Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=sha-
type=ref,event=branch
type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }}
# Build and push Docker image using docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
# Set the build context to the root of the repository (for monorepo build)
context: .
# Specify the location of the Dockerfile
file: Dockerfile.build
# Push the image to the container registry
push: true
# Use the tags generated by the docker/metadata-action
tags: ${{ steps.meta.outputs.tags }}
# Use the labels generated by the docker/metadata-action
labels: ${{ steps.meta.outputs.labels }}
# Specify build arguments to build the faims3 api project in the monorepo
build-args: |
PACKAGE_NAME=@faims3/api
NODE_RUN_DIR=api/build/src