-
Notifications
You must be signed in to change notification settings - Fork 12
106 lines (92 loc) · 3.49 KB
/
build.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
name: Build Container
on:
push:
paths:
- "Dockerfile"
- "root/**"
- ".github/workflows/build.yml"
jobs:
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-22.04
strategy:
matrix:
architecture: [linux-arm-v7, linux-arm64, linux-amd64]
steps:
- uses: actions/checkout@v4
- name: Create VARS
id: vars
run: |
ARCHITECTURE=${{ matrix.architecture }}
TIME=$(date --utc +%Y-%m-%d_%H)
echo "platform=${ARCHITECTURE//-/\/}" >> $GITHUB_OUTPUT
echo "repo=$(echo ${GITHUB_REPOSITORY//docker-/} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
echo "time=$TIME" >> $GITHUB_OUTPUT
echo "source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/tree/${GITHUB_REF//refs\/heads\//}" >> $GITHUB_OUTPUT
echo "url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/blob/master/README.md" >> $GITHUB_OUTPUT
echo "tag=$(echo ${GITHUB_REPOSITORY//docker-/} | tr '[:upper:]' '[:lower:]'):${{ matrix.architecture }}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
version: latest
driver-opts: image=moby/buildkit:master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: roxedus
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: roxedus
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
platforms: ${{ steps.vars.outputs.platform }}
file: ./Dockerfile
build-args: |
ARCH=${{ matrix.architecture }}
tags: |
${{ steps.vars.outputs.tag }}
ghcr.io/${{ steps.vars.outputs.tag }}
labels: |
org.opencontainers.image.created=${{ steps.vars.outputs.time }}
org.opencontainers.image.source=${{ steps.vars.outputs.source }}
org.opencontainers.image.url=${{ steps.vars.outputs.url }}
publish:
runs-on: ubuntu-22.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: roxedus
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: roxedus
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifests for DockerHub
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
IMAGE=$(echo ${GITHUB_REPOSITORY//docker-/} | tr '[:upper:]' '[:lower:]')
SOURCE=${IMAGE}
docker buildx imagetools create -t ${IMAGE}:latest ${SOURCE}:linux-amd64 ${SOURCE}:linux-arm-v7 ${SOURCE}:linux-arm64
- name: Create manifests for GitHub Container Registry
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
IMAGE=ghcr.io/$(echo ${GITHUB_REPOSITORY//docker-/} | tr '[:upper:]' '[:lower:]')
SOURCE=${IMAGE}
docker buildx imagetools create -t ${IMAGE}:latest ${SOURCE}:linux-amd64 ${SOURCE}:linux-arm-v7 ${SOURCE}:linux-arm64