-
Notifications
You must be signed in to change notification settings - Fork 4
136 lines (135 loc) · 5.34 KB
/
main.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: CI
on:
push:
branches:
- master
repository_dispatch:
types:
- release
env:
orgname: intersystemsdc
name: |
iris-community
irishealth-community
iris-ml-community
irishealth-ml-community
latest: 2024.1
version: |
2023.3
2023.2
2023.1.1.380.0
preview: latest-preview
jobs:
version:
runs-on: ubuntu-latest
outputs:
name: ${{ steps.set-matrix.outputs.name }}
version: ${{ steps.set-matrix.outputs.version }}
steps:
- id: set-matrix
run: |
echo name=`jq -Rsc 'split("\n") | map(select(length > 0))' <<< $'${{ env.name }}' ` >> $GITHUB_OUTPUT
echo version=`jq -Rsc 'split("\n") | map(select(length > 0))' <<< $'${{ env.latest }}\n${{ env.version }}\n${{ env.preview }}' ` >> $GITHUB_OUTPUT
build:
needs:
- version
strategy:
fail-fast: false
matrix:
name: ${{ fromJSON(needs.version.outputs.name ) }}
version: ${{ fromJSON(needs.version.outputs.version ) }}
runs-on: ubuntu-latest
steps:
- name: set variables
id: vars
run: |
echo "base=containers.intersystems.com/intersystems/${{ matrix.name }}:${{ matrix.version }}" >> $GITHUB_OUTPUT
echo "basearm=containers.intersystems.com/intersystems/${{ matrix.name }}-arm64:${{ matrix.version }}" >> $GITHUB_OUTPUT
image=${{ env.orgname }}/${{ matrix.name }}
[ '${{ secrets.DOCKER_ORGNAME }}' != '' ] && image=${{ secrets.DOCKER_ORGNAME }}/${{ matrix.name }}
version=${{ matrix.version }}-zpm
echo "image=$image" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
tags=" -t $image:$version"
[ '${{ matrix.version }}' == '${{ env.latest }}' ] && tags+=" -t $image:latest"
[ '${{ matrix.version }}' == '${{ env.preview }}' ] && tags+=" -t $image:preview"
echo "tags=$tags" >> $GITHUB_OUTPUT
tagsarm=" -t $image-arm64:$version"
[ '${{ matrix.version }}' == '${{ env.latest }}' ] && tagsarm+=" -t $image-arm64:latest"
[ '${{ matrix.version }}' == '${{ env.preview }}' ] && tagsarm+=" -t $image-arm64:preview"
echo "tagsarm=$tagsarm" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: pull docker image
uses: nick-invision/retry@v2
with:
timeout_minutes: 30
max_attempts: 3
retry_on: timeout
command: |
docker pull ${{ steps.vars.outputs.base }}
- name: pull arm64 docker image
id: pullarm
continue-on-error: true
uses: nick-invision/retry@v2
with:
timeout_minutes: 30
max_attempts: 3
retry_on: timeout
command: |
docker pull ${{ steps.vars.outputs.basearm }}
- name: docker login
id: login
continue-on-error: true
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: build x86 docker image
id: build
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: any
command: |
docker build --progress plain --no-cache --file Dockerfile-amd64 --build-arg IMAGE=${{ steps.vars.outputs.base }} --build-arg IMAGEARM=${{ steps.vars.outputs.basearm }} ${{ steps.vars.outputs.tags }} --platform linux/amd64 .
- name: push to docker hub
id: push
if: steps.login.outcome == 'success'
run: |
tags="${{ steps.vars.outputs.tags }}";tags=${tags// -t / }
echo $tags | xargs -n1 sh -c 'docker push $0'
- name: build arm64 docker image
id: buildarm
if: steps.pullarm.outcome == 'success'
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: any
command: |
docker system prune -f
docker build --progress plain --no-cache --file Dockerfile-arm64 --build-arg IMAGE=${{ steps.vars.outputs.base }} --build-arg IMAGEARM=${{ steps.vars.outputs.basearm }} ${{ steps.vars.outputs.tagsarm }} --platform linux/arm64 .
- name: push arm64 to docker hub
id: pusharm
if: steps.buildarm.outcome == 'success'
run: |
tags="${{ steps.vars.outputs.tagsarm }}";tags=${tags// -t / }
echo $tags | xargs -n1 sh -c 'docker push $0'
- name: update manifest
if: steps.push.outcome == 'success' && steps.pusharm.outcome == 'success'
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: timeout
command: |
tags="${{ steps.vars.outputs.tagsarm }}";tags=${tags// -t / }
echo $tags | xargs -n1 bash -c 'docker manifest rm ${1//-arm64/} || true' - $1
echo $tags | xargs -n1 bash -c 'docker manifest inspect ${1//-arm64/}' - $1
echo $tags | xargs -n1 bash -c 'docker manifest create ${1//-arm64/} ${1//-arm64/} $1 --amend' - $1
echo $tags | xargs -n1 bash -c 'docker manifest push ${1//-arm64/}' - $1
echo $tags | xargs -n1 bash -c 'docker manifest inspect ${1//-arm64/}' - $1