-
Notifications
You must be signed in to change notification settings - Fork 12
99 lines (99 loc) · 3.29 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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 }}