Repository navigation
100 lines (92 loc) · 3.97 KB
/
Copy pathdocker_auto.yml
File metadata and controls
100 lines (92 loc) · 3.97 KB
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
name: Automatic build on release and push to Docker Hub
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+-dev[0-9]+"
jobs:
main:
runs-on: large_runner
permissions:
contents: read
packages: write
env:
DOCKER_PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64
DOCKER_IMAGE: haproxytech/haproxy-debian
DOCKER_IMAGE_UNIFIED: haproxytech/haproxy
UNIFIED_PREFIX: debian
GHCR_IMAGE: ghcr.io/${{ github.repository }}
steps:
- name: Login to Docker Hub
id: login_docker
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Login to Container Registry
id: login_ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Check out repo
id: checkout
uses: actions/checkout@v4
- name: Prepare env variables
id: env
run: |
echo "BUILD_BRANCH=$(echo $GITHUB_REF | cut -d / -f 3 | cut -d. -f-2 | cut -d- -f1)" >> $GITHUB_ENV
echo "BUILD_VER=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV
- name: Work out image tags
id: tags
run: ./.github/image-tags.sh
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: ${{ env.BUILD_BRANCH }}
file: ${{ env.BUILD_BRANCH }}/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
labels: |
org.opencontainers.image.authors=${{ github.repository_owner }}
org.opencontainers.image.created=${{ env.BUILD_DATE }}
org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }}
org.opencontainers.image.ref.name=${{ env.GIT_REF }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ env.BUILD_VER }}
tags: ${{ steps.tags.outputs.tags }}
cache-from: type=gha,scope=${{ env.BUILD_BRANCH }}-std
cache-to: type=gha,scope=${{ env.BUILD_BRANCH }}-std,mode=max
- name: Build and push for s6
if: ${{ hashFiles(format('{0}/Dockerfile.api', env.BUILD_BRANCH)) != '' }}
id: docker_build_s6
uses: docker/build-push-action@v6
with:
context: ${{ env.BUILD_BRANCH }}
file: ${{ env.BUILD_BRANCH }}/Dockerfile.api
builder: ${{ steps.buildx.outputs.name }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
labels: |
org.opencontainers.image.authors=${{ github.repository_owner }}
org.opencontainers.image.created=${{ env.BUILD_DATE }}
org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }}
org.opencontainers.image.ref.name=${{ env.GIT_REF }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ env.BUILD_VER }}
tags: ${{ steps.tags.outputs.s6_tags }}
cache-from: type=gha,scope=${{ env.BUILD_BRANCH }}-s6
cache-to: type=gha,scope=${{ env.BUILD_BRANCH }}-s6,mode=max