-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (62 loc) · 1.92 KB
/
rebuild-image.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Rebuild image
on:
workflow_dispatch:
inputs:
directory:
description: 'Name of the directory for image - e.g. kube-oidc-proxy'
type: string
required: true
build-args:
description: 'Arguments for generating build args e.g. SOURCE_IMAGE_VERSION=1.0.6'
type: string
required: false
push:
description: 'Whether to push the image to GHCR'
type: boolean
default: false
permissions:
packages: write
jobs:
build_image:
runs-on:
- self-hosted
- small
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_READ_ONLY_USERNAME }}
password: ${{ secrets.DOCKERHUB_READ_ONLY_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Gather build args
shell: bash
id: build-args
working-directory: ./${{ inputs.directory }}
run: |
BUILD_ARGS=$(make build-args ${{ inputs.make-args }})
{
echo 'value<<EOF'
echo "$BUILD_ARGS"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
export $(echo "$BUILD_ARGS" | xargs)
echo "version=$TARGET_IMAGE_VERSION" >> "$GITHUB_OUTPUT"
- name: Build and push image
id: build
uses: docker/[email protected]
with:
context: ./${{ inputs.directory }}
platforms: linux/amd64
build-args: ${{ steps.build-args.outputs.value }}
push: ${{ inputs.push }}
load: ${{ ! inputs.push }}
tags: ${{ steps.build-args.outputs.version }}