-
Notifications
You must be signed in to change notification settings - Fork 2
143 lines (136 loc) · 5.11 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
name: build image
on:
push:
branches:
- master
- main
workflow_dispatch:
inputs:
buildtype:
description: 'Build by "force" or on "change"'
required: true
default: 'force'
repository_dispatch:
types: alpine
jobs:
compare:
runs-on: ubuntu-latest
outputs:
flag: ${{ steps.set-flag.outputs.flag }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm, arm64]
#version: [3.12, 3.14, 3.16, 3.18]
version: [3.12]
env:
name: "treehouses/alpine"
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: compare image
id: set-flag
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
tags="$name-tags"
repo="$tags:${{ matrix.arch }}"
#repo="treehouses/alpine-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 "flag=true" >> $GITHUB_ENV || echo "building on change"
[[ $reposha == *$basesha* ]] && echo "no changes" || echo "flag=true" >> $GITHUB_ENV
images:
needs: compare
runs-on: ubuntu-latest
outputs:
build: ${{ steps.set-build.outputs.build }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm, arm64]
#version: [3.12, 3.14, 3.16, 3.18]
version: [3.12]
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
if: ${{ needs.compare.outputs.flag }}
id: set-build
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
case ${{ matrix.arch }} in
amd64) : "amd64/alpine:${{ matrix.version }}" ;;
arm) : "balenalib/raspberry-pi-alpine:${{ matrix.version }}" ;;
arm64) : "arm64v8/alpine:${{ matrix.version }}" ;;
esac
image="$_"
repo="treehouses/alpine-tags"
dest="$repo:${{ matrix.arch }}"
date="$(date +%Y%m%d%H%M)"
docker build -t alpine --build-arg IMAGE=$image .
#for compatilbity reasons
if [[ "${{ matrix.version }}" == "3.12" ]]; then
docker tag alpine ghcr.io/$dest
docker tag alpine docker.io/$dest
docker tag alpine ghcr.io/$dest-$date
docker tag alpine docker.io/$dest-$date
fi
docker push --all-tags ghcr.io/$repo
docker push --all-tags docker.io/$repo
docker images
echo "::set-output name=build::true"
manifests:
needs: images
strategy:
fail-fast: false
matrix:
registry: [docker.io, ghcr.io]
#version: [3.12, 3.14, 3.16, 3.18]
version: [3.12]
runs-on: ubuntu-latest
outputs:
send: ${{ steps.set-send.outputs.send }}
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
if: ${{ needs.images.outputs.build }}
id: set-send
run: |
repo="${{ matrix.registry }}/treehouses/alpine"
date="$(date +%Y%m%d%H%M)"
docker manifest create $repo:latest $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64
docker manifest create $repo:$date $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64
docker manifest annotate $repo:latest $repo-tags:arm --os linux --arch arm
docker manifest annotate $repo:$date $repo-tags:arm --os linux --arch arm
docker manifest inspect $repo:latest
docker manifest push $repo:latest
docker manifest push $repo:$date
echo "send=true" >> $GITHUB_ENV
message:
needs: manifests
runs-on: ubuntu-latest
steps:
- name: message chat of new image
if: ${{ needs.manifests.outputs.send }}
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"