-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (108 loc) · 3.76 KB
/
docker-release-latest.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
name: "Docker CI (Latest/Testing)"
on:
pull_request:
branches: main
push:
branches: main
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: "Git: Checkout"
uses: actions/checkout@v4
-
name: "Docker: Setup QEMU"
id: qemu
uses: docker/setup-qemu-action@v3.0.0
-
name: "Docker: Setup Buildx"
id: buildx
uses: docker/setup-buildx-action@v3.1.0
-
name: "Docker: Available Platforms"
run: echo ${{ steps.buildx.outputs.platforms }}
-
name: "Env: Prepare"
id: prepare
run: |
PLATFORMS=linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x
REPONAME=$(basename $GITHUB_REPOSITORY)
DOCKER_IMAGE=padhihomelab/${REPONAME#docker_}
VERSION=testing
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
VERSION=${VERSION#_}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^(((([0-9]{1,3}\.){,3}[0-9]{1,4})|(git\..*))_){,4}((([0-9]{1,3}\.){,3}[0-9]{1,4})|(git\..*))(-p[0-9]{1,2})?$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=args::VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8}
echo ::set-output name=image::${DOCKER_IMAGE}
echo ::set-output name=platforms::${PLATFORMS}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=version::${VERSION}
-
name: "Docker: Buildx Build"
uses: docker/build-push-action@v5.3.0
with:
platforms: ${{ steps.prepare.outputs.platforms }}
push: false
tags: ${{ steps.prepare.outputs.tags }}
build-args: ${{ steps.prepare.outputs.args }}
-
name: "Docker: Load Image"
uses: docker/build-push-action@v5.3.0
with:
load: true
push: false
tags: ${{ steps.prepare.outputs.tags }}
build-args: ${{ steps.prepare.outputs.args }}
-
name: "Anchore Scan: Run"
id: scan
uses: anchore/scan-action@v3
with:
image: "${{ steps.prepare.outputs.image }}:${{ steps.prepare.outputs.version }}"
acs-report-enable: true
fail-build: false
severity-cutoff: "critical"
-
name: "Anchore Scan: Report"
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
-
name: "Docker Hub: Login"
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
-
name: "Docker: Buildx Push"
if: success() && github.event_name != 'pull_request'
uses: docker/build-push-action@v5.3.0
with:
platforms: ${{ steps.prepare.outputs.platforms }}
push: true
tags: ${{ steps.prepare.outputs.tags }}
build-args: ${{ steps.prepare.outputs.args }}
-
name: "Docker Hub: Update description"
if: success() && github.event_name != 'pull_request'
uses: peter-evans/dockerhub-description@v4
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
DOCKERHUB_REPOSITORY: ${{ steps.prepare.outputs.image }}
-
name: "Clean up"
if: always()
run: |
rm -f ${HOME}/.docker/config.json