Merge pull request #999 from joshunrau/fix-error #43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
packages: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
configure: | |
runs-on: ubuntu-latest | |
outputs: | |
current_version: ${{ steps.current_version.outputs.result }} | |
latest_published_version: ${{ steps.latest_published_version.outputs.result }} | |
is_release: ${{ steps.current_version.outputs.result != steps.latest_published_version.outputs.result }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Get Package Version | |
id: current_version | |
run: echo "result=$(cat package.json | jq -r .version)" | sudo tee -a "$GITHUB_OUTPUT" | |
- name: Run Script | |
uses: actions/github-script@v7 | |
id: latest_published_version | |
with: | |
result-encoding: string | |
script: | | |
const { getLatestPublishedVersion } = await import('${{ github.workspace }}/.github/scripts/lib.js'); | |
return await getLatestPublishedVersion({ context, exec, github }); | |
build: | |
runs-on: ubuntu-latest | |
needs: [configure] | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- dockerfile: ./apps/api/Dockerfile | |
image: ghcr.io/douglasneuroinformatics/open-data-capture-api | |
- dockerfile: ./apps/gateway/Dockerfile | |
image: ghcr.io/douglasneuroinformatics/open-data-capture-gateway | |
- dockerfile: ./apps/web/Dockerfile | |
image: ghcr.io/douglasneuroinformatics/open-data-capture-web | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Environment | |
run: ./scripts/generate-env.sh | |
- name: Set Up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set Up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Container Registry | |
if: ${{ needs.configure.outputs.is_release }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Metadata for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ matrix.image }} | |
tags: | | |
type=raw,value=latest | |
type=raw,value=${{ needs.configure.outputs.current_version }} | |
- name: Build and Push Docker Images | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
RELEASE_VERSION=${{ needs.configure.outputs.current_version }} | |
context: . | |
file: ${{ matrix.dockerfile }} | |
push: ${{ needs.configure.outputs.is_release }} | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
release: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- configure | |
permissions: | |
contents: write | |
if: ${{ needs.configure.outputs.is_release }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ needs.configure.outputs.current_version }} |