-
Notifications
You must be signed in to change notification settings - Fork 86
99 lines (95 loc) · 3.25 KB
/
golang-image.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: Build and publish golang image
on:
workflow_dispatch:
inputs:
force:
description: 'Force a build and push'
required: false
type: boolean
default: false
# Run every day at 5AM UTC
schedule:
- cron: '0 5 * * *'
env:
QUAY_ORG: projectquay
QUAY_REPO: golang
QUAY_USER: projectquay+claircore_github
jobs:
versions:
if: ${{ github.repository == 'quay/claircore' }}
name: Check available go versions
runs-on: 'ubuntu-latest'
outputs:
versions: ${{ steps.versions.outputs.versions }}
steps:
- id: versions
run: |
curl -sL 'https://golang.org/dl/?mode=json' |
jq -rc 'map(.version|sub("go(?<maj>1\\.[0-9]+)\\.[0-9]+$";"\(.maj)"))|@text "versions=\(.)"' >> $GITHUB_OUTPUT
golang-image:
if: ${{ github.repository == 'quay/claircore' }}
needs: versions
name: Build and publish golang image
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
go: ${{ fromJSON(needs.versions.outputs.versions) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check verisons and dates
run: |
v=$(.github/scripts/get-latest-golang-minor-version.sh ${{ matrix.go }})
t=$(curl -sSLf "https://quay.io/api/v1/repository/${QUAY_ORG}/${QUAY_REPO}/tag/?specificTag=${{ matrix.go }}&onlyActiveTags=true" |
jq -r '.tags[0].last_modified//"Thu, 01 Jan 1970 00:00:00 -0000"')
g=$(curl -sSLfI --http2 "https://dl.google.com/go/go${v}.linux-amd64.tar.gz" |
awk 'BEGIN {FS=": "}/^last-modified/{print $2}')
cat <<.
::notice title=Latest Go version::$v
::notice title=Latest tag update::$t
::notice title=Go version update::$g
.
cat <<. >>"$GITHUB_ENV"
GO_VERSION=$v
TAG_LAST_MODIFIED=$t
GO_LAST_MODIFIED=$g
.
- name: Decide whether we need to build new golang image
run: |
TAG=$(date -d "${TAG_LAST_MODIFIED}" +%s)
GO=$(date -d "${GO_LAST_MODIFIED}" +%s)
if test "${{ inputs.force }}" = 'true' -o "$GO" -gt "$TAG"; then
echo "BUILD_IMAGE=1" >> "$GITHUB_ENV"
fi
- name: Set up QEMU
if: env.BUILD_IMAGE == 1
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Build
uses: redhat-actions/buildah-build@v2
if: env.BUILD_IMAGE == 1
with:
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
containerfiles: etc/Dockerfile
context: etc
tags: |
quay.io/${{ env.QUAY_ORG }}/${{ env.QUAY_REPO }}:${{ matrix.go }}
- uses: redhat-actions/podman-login@v1
if: env.BUILD_IMAGE == 1
with:
registry: quay.io
username: ${{ env.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Publish
uses: redhat-actions/push-to-registry@v2
if: env.BUILD_IMAGE == 1
with:
#extra-args: |
# --compression-format=zstd:chunked
tags: |
quay.io/${{ env.QUAY_ORG }}/${{ env.QUAY_REPO }}:${{ matrix.go }}