-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (107 loc) · 3.52 KB
/
_build.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
name: generic build
on:
workflow_call:
inputs:
registry:
description: 'Docker registry'
type: string
default: 'ghcr.io'
platforms:
description: 'Platforms to build for, comma separated list of arch/os pairs'
required: false
type: string
default: 'linux/amd64'
runs-on:
description: 'Runner to use'
required: false
type: string
default: 'ubuntu-latest'
secrets:
username:
description: 'username at registry'
required: false
password:
description: 'password at registry'
required: false
jobs:
build:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
-
name: Latest Version
id: version
uses: efrecon/gh-action-releases@main
with:
project: cloudflare/cloudflared
-
name: Login at registry
uses: docker/login-action@v3
if: ${{ ! startsWith(inputs.registry, 'localhost') }}
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.username }}
password: ${{ secrets.password }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ startsWith(inputs.registry, 'localhost') }}
with:
driver-opts: network=host
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ ! startsWith(inputs.registry, 'localhost') }}
-
name: Check Presence
id: present
run: |
if docker manifest inspect "${{ inputs.registry }}/${{ github.repository_owner }}/cloudflared:${{ steps.version.outputs.latest }}" 2>/dev/null; then
printf "present=true\n" >> "$GITHUB_OUTPUT"
else
printf "present=false\n" >> "$GITHUB_OUTPUT"
fi
-
name: Build and push cloudflared Image
uses: docker/build-push-action@v5
id: cloudflared
if: steps.present.outputs.present == 'false'
with:
push: true
file: Dockerfile.cloudflared
platforms: ${{ inputs.platforms }}
tags: |
${{ inputs.registry }}/${{ github.repository_owner }}/cloudflared:${{ steps.version.outputs.latest }}
build-args: |
CLOUDFLARED_VERSION=${{ steps.version.outputs.latest }}
-
name: Build and push Base Image
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile.base
platforms: ${{ inputs.platforms }}
build-args: |
BASEIMAGE=${{ inputs.registry }}/${{ github.repository_owner }}/cloudflared:${{ steps.version.outputs.latest }}
tags: |
${{ inputs.registry }}/${{ github.repository }}-base:${{ steps.version.outputs.latest }}
${{ inputs.registry }}/${{ github.repository }}-base:latest
-
name: Build and push Main Image
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile
platforms: ${{ inputs.platforms }}
build-args: |
BASEIMAGE=${{ inputs.registry }}/${{ github.repository }}-base:${{ steps.version.outputs.latest }}
tags: |
${{ inputs.registry }}/${{ github.repository }}:${{ steps.version.outputs.latest }}
${{ inputs.registry }}/${{ github.repository }}:latest