-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (86 loc) · 3.14 KB
/
msupply.yml
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: Open mSupply server
on:
pull_request:
paths:
- msupply-server/**
- .github/workflows/msupply.yml
push:
branches:
- main
paths:
- msupply-server/**
- .github/workflows/msupply.yml
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions:
contents: read
id-token: write
attestations: write
packages: write
env:
MSUPPLY_VERSION: 2.5.1
jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- arch: amd64
runs-on: ubuntu-24.04
- arch: arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Verify docker works
run: docker run hello-world
- name: Checkout source
uses: actions/checkout@v4
- name: Setup buildkit
uses: docker/setup-buildx-action@v2
- uses: docker/metadata-action@v5
id: meta
with:
labels: |
org.opencontainers.image.title=Open mSupply server
org.opencontainers.image.url=https://msupply.foundation/open-msupply/
org.opencontainers.image.source=https://github.com/msupply-foundation/open-msupply
org.opencontainers.image.version=${{ env.MSUPPLY_VERSION }}
org.opencontainers.image.licenses=AGPL-3.0
- name: Build and push
id: build
uses: docker/build-push-action@v5
with:
context: msupply-server
file: msupply-server/Dockerfile
platforms: linux/${{ matrix.platform.arch }}
cache-from: type=gha,scope=msupply-${{ matrix.platform.arch }}
cache-to: type=gha,mode=max,scope=msupply-${{ matrix.platform.arch }}
build-args: MSUPPLY_REF=v${{ env.MSUPPLY_VERSION }}
push: ${{ github.event_name == 'push' }} # ie to main
labels: ${{ steps.meta.outputs.labels }}
tags: ghcr.io/beyondessential/msupply-server:v${{ env.MSUPPLY_VERSION }}.${{ matrix.platform.arch }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/beyondessential/msupply-server:v${{ env.MSUPPLY_VERSION }}.${{ matrix.platform.arch }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true
multi-arch:
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
name: Multi-arch image
steps:
- name: Install manifest-tool
run: |
curl -sLo manifest-tool.tar.gz https://github.com/estesp/manifest-tool/releases/download/v2.1.5/binaries-manifest-tool-2.1.5.tar.gz
tar -xvf manifest-tool.tar.gz manifest-tool-linux-amd64
mv manifest-tool-linux-amd64 manifest-tool
chmod +x manifest-tool
- name: Combine images
run: |
./manifest-tool push from-args \
--platforms linux/amd64,linux/arm64 \
--template ghcr.io/beyondessential/msupply-server:v${{ env.MSUPPLY_VERSION }}.ARCH \
--target ghcr.io/beyondessential/msupply-server:v${{ env.MSUPPLY_VERSION }}