-
Notifications
You must be signed in to change notification settings - Fork 4
119 lines (110 loc) · 4.08 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
name: images
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '30 9 * * 1'
workflow_dispatch:
# https://github.com/docker/build-push-action/issues/461
# https://github.com/docker/build-push-action/issues/906#issuecomment-1674567311
jobs:
build_old:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
image-name: ["server-base", "secret-generation"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.image-name }}
push: ${{ github.event_name == 'push' && github.repository == 'DIRACGrid/container-images' && github.ref_name == 'main' }}
tags: ghcr.io/diracgrid/diracx/${{ matrix.image-name }}:latest
platforms: linux/amd64,linux/arm64
build:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build base
id: build_base
uses: docker/build-push-action@v5
with:
context: base
outputs: type=oci,dest=output-base.tar
tags: ghcr.io/diracgrid/diracx/base:latest
platforms: linux/amd64,linux/arm64
- name: Extract base
run: |
mkdir output-base
tar -C output-base -xf output-base.tar
- name: Build services-base
uses: docker/build-push-action@v5
with:
context: services-base
build-contexts: |
ghcr.io/diracgrid/diracx/base=oci-layout://output-base@${{steps.build_base.outputs.digest}}
outputs: type=oci,dest=output-services-base.tar
tags: ghcr.io/diracgrid/diracx/services-base:latest
platforms: linux/amd64,linux/arm64
- name: Extract services-base
run: |
mkdir output-services-base
tar -C output-services-base -xf output-services-base.tar
- name: Build client-base
uses: docker/build-push-action@v5
with:
context: client-base
build-contexts: |
ghcr.io/diracgrid/diracx/base=oci-layout://output-base@${{steps.build_base.outputs.digest}}
outputs: type=oci,dest=output-client-base.tar
tags: ghcr.io/diracgrid/diracx/client-base:latest
platforms: linux/amd64,linux/arm64
- name: Extract client-base
run: |
mkdir output-client-base
tar -C output-client-base -xf output-client-base.tar
- name: Push images
if: ${{ github.event_name != 'pull_request' && github.repository == 'DIRACGrid/container-images' && github.ref_name == 'main' }}
run: |
image_version=$(date +'%Y.%m.%d')
# Check how many tags already exist for the current date and increment the version
count=$(oras repo tags "ghcr.io/diracgrid/diracx/base" | grep -c "${image_version}" || echo "0")
image_version=${image_version}.${count}
echo "Pushing version ${image_version}"
for image_name in base services-base client-base; do
image_repo=ghcr.io/diracgrid/diracx/${image_name}
oras cp --from-oci-layout "$PWD/output-${image_name}:latest" "${image_repo}:latest"
oras cp "${image_repo}:latest" "${image_repo}:${image_version}"
done