Repository navigation
96 lines (86 loc) · 3.2 KB
/
Copy pathdocker-build-multi-arch.yml
File metadata and controls
96 lines (86 loc) · 3.2 KB
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
name: Docker build (multi-arch)
on:
workflow_dispatch:
inputs:
tag:
description: Existing annotated release tag to build (e.g. 0.35)
required: true
type: string
publish:
description: Publish the image to Docker Hub
type: boolean
default: false
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
concurrency:
group: docker-${{ inputs.tag }}
cancel-in-progress: false
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out release
uses: actions/checkout@v5
with:
ref: refs/tags/${{ inputs.tag }}
fetch-depth: 0
- name: Read build metadata
id: build_metadata
shell: bash
env:
RELEASE_TAG: ${{ inputs.tag }}
run: |
perl scripts/check-release.pl "$RELEASE_TAG"
version="$(tr -d '\r\n' < VERSION)"
test -n "$version"
git fetch --force origin "refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG"
if [[ "$(git cat-file -t "refs/tags/$RELEASE_TAG")" != "tag" ]]; then
echo "Docker release tag $RELEASE_TAG must be annotated" >&2
exit 1
fi
if [[ "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" != "$(git rev-parse HEAD)" ]]; then
echo "Checked-out commit does not match Docker release tag $RELEASE_TAG" >&2
exit 1
fi
if [[ "$RELEASE_TAG" != "$version" ]]; then
echo "Docker tag $RELEASE_TAG does not match VERSION $version" >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: inputs.publish
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push multi-arch image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: ${{ inputs.publish }}
tags: |
manuelrueda/convert-pheno:${{ steps.build_metadata.outputs.version }}
manuelrueda/convert-pheno:latest
platforms: linux/amd64,linux/arm64
build-args: |
BUILD_VERSION=${{ steps.build_metadata.outputs.version }}
VCS_REF=${{ steps.build_metadata.outputs.revision }}
labels: |
org.opencontainers.image.title=Convert-Pheno
org.opencontainers.image.description=Clinical and phenotypic data model converter
org.opencontainers.image.source=https://github.com/CNAG-Biomedical-Informatics/convert-pheno
org.opencontainers.image.version=${{ steps.build_metadata.outputs.version }}
org.opencontainers.image.revision=${{ steps.build_metadata.outputs.revision }}
org.opencontainers.image.licenses=Artistic-2.0
cache-from: type=gha
cache-to: type=gha,mode=max