-
Notifications
You must be signed in to change notification settings - Fork 2
162 lines (156 loc) · 6.28 KB
/
alpine.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: build image
on:
push:
branches:
- master
- main
workflow_dispatch:
inputs:
buildtype:
description: 'building by "force" or on "change"'
required: true
default: 'force'
repository_dispatch:
types: alpine
jobs:
compare:
runs-on: ubuntu-latest
outputs:
images: ${{ steps.images.outputs.images }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm, arm64]
version: [3.12, 3.14, 3.16, 3.18]
env:
name: "treehouses/alpine"
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: compare image
id: images
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
tags="$name-tags"
repo="$tags:${{ matrix.arch }}-${{ matrix.version }}"
case ${{ matrix.arch }} in
amd64) : "amd64/alpine:${{ matrix.version }}" ;;
arm) : "balenalib/raspberry-pi-alpine:${{ matrix.version }}" ;;
arm64) : "arm64v8/alpine:${{ matrix.version }}" ;;
esac
base="$_"
docker pull -q $base &>/dev/null
docker pull -q $repo &>/dev/null
basesha=$(docker image inspect $base | jq --raw-output '.[0].RootFS.Layers|.[]')
reposha=$(docker image inspect $repo | jq --raw-output '.[0].RootFS.Layers|.[]')
echo "base sha:$basesha repo sha:$reposha"
${{ github.event.inputs.buildtype == 'force' }} && echo "images=true" >> $GITHUB_OUTPUT || echo "no force"
[[ $reposha == *$basesha* ]] && echo "no changes" || echo "images=true" >> $GITHUB_OUTPUT
images:
needs: compare
if: ${{ needs.compare.outputs.images }}
runs-on: ubuntu-latest
outputs:
manifests: ${{ steps.manifests.outputs.manifests }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm, arm64]
version: [3.12, 3.14, 3.16, 3.18]
env:
name: "treehouses/alpine"
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: container registries
run: |
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
docker login docker.io -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}
- name: docker image
id: manifests
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
tags="$name-tags"
repo="$tags:${{ matrix.arch }}"
more="$repo-${{ matrix.version }}"
case ${{ matrix.arch }} in
amd64) : "amd64/alpine:${{ matrix.version }}" ;;
arm) : "balenalib/raspberry-pi-alpine:${{ matrix.version }}" ;;
arm64) : "arm64v8/alpine:${{ matrix.version }}" ;;
esac
base="$_"
time=$(date +%Y%m%d%H%M)
date="$repo-$time"
full="$more-$time"
docker build -t image --build-arg BASE=$base .
#for compatilbity reasons
if [[ "${{ matrix.version }}" == "3.12" ]]; then
docker tag image ghcr.io/$repo
docker tag image docker.io/$repo
docker tag image ghcr.io/$date
docker tag image docker.io/$date
fi
docker tag image ghcr.io/$more
docker tag image docker.io/$more
docker tag image ghcr.io/$full
docker tag image docker.io/$full
docker push --all-tags ghcr.io/$tags
docker push --all-tags docker.io/$tags
docker images
echo "manifests=true" >> $GITHUB_OUTPUT
manifests:
needs: images
if: ${{ needs.images.outputs.manifests }}
strategy:
fail-fast: false
matrix:
registry: [docker.io, ghcr.io]
version: [3.12, 3.14, 3.16, 3.18]
runs-on: ubuntu-latest
outputs:
message: ${{ steps.message.outputs.message }}
env:
name: "${{ matrix.registry }}/treehouses/alpine"
steps:
- name: container registries
run: |
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
docker login docker.io -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}
- name: create manifests
id: message
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
tags="$name-tags"
date="$(date +%Y%m%d%H%M)"
#for compatilbity reasons
if [[ "${{ matrix.version }}" == "3.12" ]]; then
docker manifest create $name:latest $tags:amd64 $tags:arm $tags:arm64
docker manifest annotate $name:latest $tags:arm --os linux --arch arm
docker manifest inspect $name:latest
docker manifest push $name:latest
docker manifest create $name:$date $tags:amd64 $tags:arm $tags:arm64
docker manifest annotate $name:$date $tags:arm --os linux --arch arm
docker manifest inspect $name:$date
docker manifest push $name:$date
fi
docker manifest create $name:${{ matrix.version }} $tags:amd64-${{ matrix.version }} $tags:arm-${{ matrix.version }} $tags:arm64-${{ matrix.version }}
docker manifest annotate $name:${{ matrix.version }} $tags:arm-${{ matrix.version }} --os linux --arch arm
docker manifest inspect $name:${{ matrix.version }}
docker manifest push $name:${{ matrix.version }}
docker manifest create $name:${{ matrix.version }}-$date $tags:amd64-${{ matrix.version }} $tags:arm-${{ matrix.version }} $tags:arm64-${{ matrix.version }}
docker manifest annotate $name:${{ matrix.version }}-$date $tags:arm-${{ matrix.version }} --os linux --arch arm
docker manifest inspect $name:${{ matrix.version }}-$date
docker manifest push $name:${{ matrix.version }}-$date
echo "message=true" >> $GITHUB_OUTPUT
message:
needs: manifests
if: ${{ needs.manifests.outputs.message }}
runs-on: ubuntu-latest
steps:
- name: message chat of new image
run: |
sudo npm install -g @treehouses/cli
export discord_channel="${{ secrets.CHANNEL }}"
echo "https://hub.docker.com/r/treehouses/alpine/tags"
echo "https://github.com/treehouses/alpine/pkgs/container/alpine"
treehouses feedback "new treehouses/alpine check https://hub.docker.com/r/treehouses/alpine/tags or https://github.com/treehouses/alpine/pkgs/container/alpine"