-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (52 loc) · 1.67 KB
/
docker-build.yaml
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
name: Docker Build, Push
on:
push:
branches:
- '*'
tags-ignore:
- 'release/*'
jobs:
docker:
env:
IMAGE: img.hephy.pro/fluxcd/flux-pr-review
runs-on: self-hosted
steps:
- name: Prepare
id: prep
run: |
BRANCH=${GITHUB_REF##*/}
TS=$(date +%s)
REVISION=${GITHUB_SHA::8}
BUILD_ID="${BRANCH}-${REVISION}-${TS}"
LATEST_ID=canary
if [[ $GITHUB_REF == refs/tags/* ]]; then
BUILD_ID=${GITHUB_REF/refs\/tags\//}
LATEST_ID=latest
fi
echo BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') >> $GITHUB_OUTPUT
echo BUILD_ID=${BUILD_ID} >> $GITHUB_OUTPUT
echo LATEST_ID=${LATEST_ID} >> $GITHUB_OUTPUT
#- name: Set up QEMU
# uses: docker/setup-qemu-action@v1
#- name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: img.hephy.pro
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- uses: actions/checkout@v3
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ env.IMAGE }}:${{ steps.prep.outputs.BUILD_ID }}
${{ env.IMAGE }}:${{ steps.prep.outputs.LATEST_ID }}
#cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
#cache-to: type=registry,ref=${{ env.IMAGE}}:buildcache,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}