-
Notifications
You must be signed in to change notification settings - Fork 9
144 lines (121 loc) · 4.55 KB
/
busybox-containers.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
name: "BusyBox 🐳 Mirror"
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- '*'
paths:
- containers.yml
- '.github/workflows/busybox-containers.yml'
- 'mirrors/busybox/*'
pull_request:
paths:
- containers.yml
- '.github/workflows/busybox-containers.yml'
- 'mirrors/busybox/*'
env:
PATH_IN_REPO: mirrors/busybox
concurrency:
# Concurrency is defined in a way that concurrent builds against branches do
# not cancel previous builds.
# However, for every new build against the same pull request source branch,
# all older builds against that same branch get canceled.
group: mirrors/busybox-${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
matrix-generator:
name: "Mirror Matrix Generator"
runs-on: ubuntu-latest
outputs:
dockerinfo: ${{ steps.set-matrix.outputs.dockerinfo }}
steps:
- name: "Throttle Builds"
run: |
t=$(shuf -i 5-30 -n 1); echo "Sleeping $t seconds"; sleep $t
- name: "Fetching Repository Contents"
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Requirements
run: |
python -m pip install -r requirements.txt
- name: "Generate Matrix Data"
id: set-matrix
run: |
inv containers.matrix --from-workflow ${{ env.PATH_IN_REPO }}
mirror-image:
runs-on: ubuntu-latest
needs: matrix-generator
name: "${{ matrix.dockerinfo.name }}"
strategy:
fail-fast: false
max-parallel: 4
matrix:
dockerinfo: ${{ fromJson(needs.matrix-generator.outputs.dockerinfo) }}
permissions:
actions: read
checks: write
issues: read
packages: write
pull-requests: read
repository-projects: read
statuses: read
steps:
- name: "Fetching Repository Contents"
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Requirements
run: |
python -m pip install -r requirements.txt
- name: "Throttle concurrent pushes"
run: |
t=$(shuf -i 5-30 -n 1); echo "Sleeping $t seconds"; sleep $t
- name: "Setup DockerFile"
run: |
echo " " >> ./${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.source=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.url=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.documentation=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}}
echo "LABEL org.opencontainers.image.vendor=\"Unofficial Docker Hub Mirror\"" >> ${{matrix.dockerinfo.file}}
cat ./${{matrix.dockerinfo.file}}
- name: "Docker QEMU"
uses: docker/setup-qemu-action@v2
- name: "Docker BuildX"
id: buildx
uses: docker/setup-buildx-action@v2
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Inspect Source Image
run: |
docker buildx imagetools inspect busybox:musl | tee -a source-container-inspect.txt
- name: Define Build Platforms
id: define-platforms
run: |
inv containers.platforms --exclude=linux/s390x,linux/mips64le source-container-inspect.txt
- name: "Log into GitHub Container Registry"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build & Publish"
uses: docker/build-push-action@v3
with:
file: ${{ matrix.dockerinfo.file }}
context: ${{ env.PATH_IN_REPO }}
platforms: ${{ steps.define-platforms.outputs.platforms }}
push: ${{ github.repository == 'saltstack/salt-ci-containers' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
tags: |
ghcr.io/${{ github.repository }}/${{ matrix.dockerinfo.name }}