-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (68 loc) · 2.12 KB
/
Copy pathdockerx-build.yml
File metadata and controls
68 lines (68 loc) · 2.12 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
name: DockerX Build (reusable)
on:
workflow_call:
inputs:
dockerfile:
description: "Path to the Dockerfile to build"
required: true
type: string
context:
description: "Logical context identifier (eg: pushi)"
required: true
type: string
platforms:
description: "Comma-separated list of target platforms"
required: true
type: string
tag_suffix:
description: "Suffix appended to the computed base tag (eg: \"-amd64\")"
required: false
type: string
default: ""
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true
jobs:
build:
name: Build
timeout-minutes: 180
runs-on: [self-hosted, ubuntu, latest]
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
submodules: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set build variables
id: set_vars
run: |
echo "build_date=$(date +%s)" >> $GITHUB_OUTPUT
if [[ "${{ github.ref_name }}" == "master" ]]; then
base_tag="latest"
else
ref_name=${{ github.ref_name }}
BRANCH_NAME=${ref_name//\//_}
base_tag="$BRANCH_NAME"
fi
echo "tag=${base_tag}${{ inputs.tag_suffix }}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ${{ inputs.dockerfile }}
platforms: ${{ inputs.platforms }}
push: true
tags: hivesolutions/pushi:${{ steps.set_vars.outputs.tag }}
build-args: |
GIT_COMMIT=${{ github.sha }}
BUILD_DATE=${{ steps.set_vars.outputs.build_date }}