-
Notifications
You must be signed in to change notification settings - Fork 3
140 lines (124 loc) · 5.54 KB
/
build_docker-dhi_helper.yml
File metadata and controls
140 lines (124 loc) · 5.54 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
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
name: 'docker: DHI + Helper'
on:
#push:
# branches:
# - 'main'
# - 'master'
# paths:
# - 'dhi.alpine.helper.Dockerfile'
# - '.github/workflows/build_docker-dhi_helper.yml'
workflow_dispatch:
schedule:
- cron: '45 2 25 * *' # At 02:45 on day-of-month 25.
defaults:
run:
shell: bash
jobs:
# --------------------------------------------------
# JOB: PREPARE (Variables)
# --------------------------------------------------
prepare:
name: Prepare build variables
runs-on: ubuntu-latest
steps:
#- name: Checkout
# uses: actions/checkout@v6
- name: Generate build variables
id: vars
shell: bash
run: |
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}"
#COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
COMMIT_HASH=${GITHUB_SHA::7}
GIT_URL=$(echo "${GITHUB_SERVER_URL}" | awk -F/ '{print $3}' | sed 's/\/*$//')
GIT_URL=$(echo "$GIT_URL" | sed 's/github\.com/ghcr\.io/g') # GIT_URL switch to ghcr.io registry for GitHub
GIT_REPO=${GITHUB_REPOSITORY,,}
GIT_REPO_SHORT=${GIT_REPO#*/}
GIT_REPO_SHORT=${GIT_REPO_SHORT#"docker-"}
DOCKER_REPO=${{ vars.DOCKER_USERNAME }}/${GIT_REPO_SHORT}
REDHAT_QUAY_REPO=${{ vars.REDHAT_QUAY_USERNAME }}/${GIT_REPO_SHORT}
#echo "ENVs: BUILD_DATE=${BUILD_DATE}, BUILD_DATE_NUMERIC=${BUILD_DATE_NUMERIC}, COMMIT_HASH=${COMMIT_HASH}, GIT_URL=${GIT_URL}, GIT_REPO=${GIT_REPO}, DOCKER_REPO=${DOCKER_REPO}, REDHAT_QUAY_REPO=${REDHAT_QUAY_REPO}"
# Set output parameters to action.
echo "build_date=${BUILD_DATE}" >> "$GITHUB_OUTPUT"
echo "build_date_numeric=${BUILD_DATE_NUMERIC}" >> "$GITHUB_OUTPUT"
echo "commit_hash=${COMMIT_HASH}" >> "$GITHUB_OUTPUT"
echo "git_url=${GIT_URL}" >> "$GITHUB_OUTPUT"
echo "git_repo=${GIT_REPO}" >> "$GITHUB_OUTPUT"
echo "git_repo_short=${GIT_REPO_SHORT}" >> "$GITHUB_OUTPUT"
echo "docker_repo=${DOCKER_REPO}" >> "$GITHUB_OUTPUT"
echo "redhat_quay_repo=${REDHAT_QUAY_REPO}" >> "$GITHUB_OUTPUT"
outputs:
build_date: ${{ steps.vars.outputs.build_date }}
build_date_numeric: ${{ steps.vars.outputs.build_date_numeric }}
commit_hash: ${{ steps.vars.outputs.commit_hash }}
git_url: ${{ steps.vars.outputs.git_url }}
git_repo: ${{ steps.vars.outputs.git_repo }}
git_repo_short: ${{ steps.vars.outputs.git_repo_short }}
docker_repo: ${{ steps.vars.outputs.docker_repo }}
quay_repo: ${{ steps.vars.outputs.redhat_quay_repo }}
# --------------------------------------------------
# JOB: DHI Alpine Helper
# --------------------------------------------------
build-dhi-helper-alpine:
name: Build DHI Helper (Alpine)
runs-on: ubuntu-latest
needs: prepare
env:
BUILD_DATE: ${{ needs.prepare.outputs.build_date }}
BUILD_DATE_NUMERIC: ${{ needs.prepare.outputs.build_date_numeric}}
COMMIT_HASH: ${{ needs.prepare.outputs.commit_hash }}
GIT_URL: ${{ needs.prepare.outputs.git_url }}
GIT_REPO: ${{ needs.prepare.outputs.git_repo }}
GIT_REPO_SHORT: ${{ needs.prepare.outputs.git_repo_short }}
DOCKER_REPO: ${{ needs.prepare.outputs.docker_repo }}
QUAY_REPO: ${{ needs.prepare.outputs.quay_repo }}
PHP_VERSION: ${{ matrix.php }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Debug Variables
run: |
echo "BUILD_DATE=${BUILD_DATE}"
echo "BUILD_DATE_NUMERIC=${BUILD_DATE_NUMERIC}"
echo "COMMIT_HASH=${COMMIT_HASH}"
echo "GIT_URL=${GIT_URL}"
echo "GIT_REPO=${GIT_REPO}"
echo "GIT_REPO_SHORT=${GIT_REPO_SHORT}"
echo "DOCKER_REPO=${DOCKER_REPO}"
echo "QUAY_REPO=${QUAY_REPO}"
- name: Execute Docker Setup
id: docker-setup
uses: ./.github/actions/docker-setup
#uses: tob1as/docker-build-example/.github/actions/docker-setup@main
with:
git_url: ${{ env.GIT_URL }}
git_username: ${{ github.repository_owner }}
git_token: ${{ secrets.GITHUB_TOKEN }}
docker_username: ${{ vars.DOCKER_USERNAME }}
docker_password: ${{ secrets.DOCKER_PASSWORD }}
quay_username: ${{ vars.REDHAT_QUAY_USERNAME }}
quay_password: ${{ secrets.REDHAT_QUAY_PASSWORD }}
- name: Build
uses: docker/build-push-action@v6
with:
builder: ${{ steps.docker-setup.outputs.builder_name }}
context: .
file: ./dhi.alpine.helper.Dockerfile
platforms: linux/amd64,linux/arm64
pull: true
push: true
target: production-alpine
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
VCS_REF=${{ env.COMMIT_HASH }}
tags: |
docker.io/${{env.DOCKER_REPO}}:dhi-helper-alpine
docker.io/${{env.DOCKER_REPO}}:dhi-helper-alpine-${{env.COMMIT_HASH}}
docker.io/${{env.DOCKER_REPO}}:dhi-helper-alpine-${{env.BUILD_DATE_NUMERIC}}
quay.io/${{env.QUAY_REPO}}:dhi-helper-alpine
quay.io/${{env.QUAY_REPO}}:dhi-helper-alpine-${{env.COMMIT_HASH}}
quay.io/${{env.QUAY_REPO}}:dhi-helper-alpine-${{env.BUILD_DATE_NUMERIC}}
# ${{env.GIT_URL}}/${{env.GIT_REPO}}:dhi-helper-alpine
# ${{env.GIT_URL}}/${{env.GIT_REPO}}:dhi-helper-alpine-${{env.COMMIT_HASH}}
# ${{env.GIT_URL}}/${{env.GIT_REPO}}:dhi-helper-alpine-${{env.BUILD_DATE_NUMERIC}}