-
Notifications
You must be signed in to change notification settings - Fork 1
121 lines (120 loc) · 4.77 KB
/
build-images.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
on:
push:
branches:
- master
schedule:
- cron: '0 4 * * 0'
jobs:
build-image:
strategy:
fail-fast: false
matrix:
pyver: ["3.9","3.10", "3.12"]
include:
- pyver: "3.11"
main: true
runs-on: ubuntu-latest
name: Build Python ${{ matrix.pyver }} Image
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set Names
id: names
run: |
MR="ghcr.io/oggm"
DI="$(date +%Y%m%d)"
PV="${{ matrix.pyver }}"
[[ "$PV" == py* ]] || PV="py$PV"
echo "vertag=$PV" >> $GITHUB_OUTPUT
echo "dev=$MR/dev_base" >> $GITHUB_OUTPUT
echo "empty=$MR/empty_base" >> $GITHUB_OUTPUT
echo "untested=$MR/untested_base" >> $GITHUB_OUTPUT
echo "base=$MR/base" >> $GITHUB_OUTPUT
if [[ "${{ matrix.main }}" == "true" ]]; then
echo "dev_latest=$MR/dev_base:latest" >> $GITHUB_OUTPUT
echo "dev_date=$MR/dev_base:$DI" >> $GITHUB_OUTPUT
echo "empty_latest=$MR/empty_base:latest" >> $GITHUB_OUTPUT
echo "empty_date=$MR/empty_base:$DI" >> $GITHUB_OUTPUT
echo "untested_latest=$MR/untested_base:latest" >> $GITHUB_OUTPUT
echo "untested_date=$MR/untested_base:$DI" >> $GITHUB_OUTPUT
echo "base_latest=$MR/base:latest" >> $GITHUB_OUTPUT
echo "base_date=$MR/base:$DI" >> $GITHUB_OUTPUT
fi
- name: Stop Commands
run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
- name: Generate Dockerfile
run: make -C untested_base PYTHON_VERSION="${{ matrix.pyver }}" Dockerfile_dev Dockerfile_empty
- name: Build dev_base
id: dev_base
uses: docker/build-push-action@v6
with:
context: untested_base
file: untested_base/Dockerfile_dev
pull: true
push: true
provenance: false
tags: |
${{ steps.names.outputs.dev }}:${{ steps.names.outputs.vertag }}
${{ steps.names.outputs.dev_latest }}
${{ steps.names.outputs.dev_date }}
cache-to: type=registry,mode=max,ref=${{ steps.names.outputs.dev }}:cache_${{ steps.names.outputs.vertag }}
cache-from: type=registry,ref=${{ steps.names.outputs.dev }}:cache_${{ steps.names.outputs.vertag }}
- name: Build empty_base
id: empty_base
uses: docker/build-push-action@v6
with:
context: untested_base
file: untested_base/Dockerfile_empty
pull: true
push: true
provenance: false
tags: |
${{ steps.names.outputs.empty }}:${{ steps.names.outputs.vertag }}
${{ steps.names.outputs.empty_latest }}
${{ steps.names.outputs.empty_date }}
cache-to: type=registry,mode=max,ref=${{ steps.names.outputs.empty }}:cache_${{ steps.names.outputs.vertag }}
cache-from: type=registry,ref=${{ steps.names.outputs.empty }}:cache_${{ steps.names.outputs.vertag }}
- name: Generate Final Dockerfile
run: make -C untested_base PYTHON_VERSION="${{ matrix.pyver }}" DEV_TAG="${{ steps.names.outputs.dev }}@${{ steps.dev_base.outputs.digest }}" EMPTY_TAG="${{ steps.names.outputs.empty }}@${{ steps.empty_base.outputs.digest }}" Dockerfile_final
- name: Build untested_base
uses: docker/build-push-action@v6
with:
context: untested_base
file: untested_base/Dockerfile_final
pull: true
push: true
provenance: false
tags: |
${{ steps.names.outputs.untested }}:${{ steps.names.outputs.vertag }}
${{ steps.names.outputs.untested_latest }}
${{ steps.names.outputs.untested_date }}
cache-to: type=registry,mode=max,ref=${{ steps.names.outputs.untested }}:cache_${{ steps.names.outputs.vertag }}
cache-from: type=registry,ref=${{ steps.names.outputs.untested }}:cache_${{ steps.names.outputs.vertag }}
- name: Test image
run: docker run --rm "${{ steps.names.outputs.untested }}:${{ steps.names.outputs.vertag }}" /root/test.sh
- name: Build base
uses: docker/build-push-action@v6
if: ${{ matrix.main }}
with:
context: base
push: true
provenance: false
tags: |
${{ steps.names.outputs.base_latest }}
${{ steps.names.outputs.base_date }}
- name: Trigger OGGM
if: ${{ matrix.main }}
uses: OGGM/repo-dispatch-action@v1
with:
repo: OGGM/oggm
auth_user: ${{ secrets.DispatchUser }}
auth_secret: ${{ secrets.DispatchSecret }}
action: build-docker-image