-
Notifications
You must be signed in to change notification settings - Fork 13
89 lines (84 loc) · 2.92 KB
/
publish-dev-docker-image.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
---
# yamllint disable rule:truthy rule:line-length
name: Publish development docker image
on:
workflow_dispatch:
inputs:
publish:
type: boolean
description: Publish the image
default: false
required: true
commit:
type: string
description: commit sha or branch name
default: ''
required: false
platforms:
type: string
description: Comma separated platform list to build the image for
default: "linux/amd64,linux/arm64"
tag:
type: string
description: additional image tag
default: ''
required: false
pull_request:
types:
- labeled
- synchronize
jobs:
meta_data:
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'cd/preview')
runs-on:
group: huge-runners
outputs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
ref: ${{ steps.ref.outputs.ref }}
short_ref: ${{ steps.short_ref.outputs.short_ref }}
steps:
- name: Set GIT ref
run: echo "ref=${{ inputs.commit == '' && (github.event.pull_request.head.sha == '' && github.sha || github.event.pull_request.head.sha) || inputs.commit }} " >> $GITHUB_OUTPUT
id: ref
- name: Set GIT short ref
run: echo "short_ref=$(echo ${{ steps.ref.outputs.ref }} | cut -c1-7)" >> $GITHUB_OUTPUT
id: short_ref
- name: Set docker image meta data
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ vars.HARBOR_HOST }}/${{ github.repository }}
tags: |
type=raw,value=dev-${{ steps.short_ref.outputs.short_ref }}
type=raw,value=${{ inputs.tag }}
labels: |
org.opencontainers.image.source=${{ github.repository }}
org.opencontainers.image.version=dev-${{ steps.short_ref.outputs.short_ref }}
flavor: |
latest=false
publish-docker-image-dispatch:
if: github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/ci-docker-image.yml
needs: meta_data
secrets: inherit
with:
publish: ${{ inputs.publish }}
version: dev-${{ needs.meta_data.outputs.short_ref }}
ref: ${{ needs.meta_data.outputs.ref }}
tags: ${{needs.meta_data.outputs.tags}}
labels: ${{needs.meta_data.outputs.labels}}
platforms: ${{ inputs.platforms }}
publish-docker-image-pr:
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cd/preview')
uses: ./.github/workflows/ci-docker-image.yml
needs: meta_data
secrets: inherit
with:
publish: true
version: dev-${{ needs.meta_data.outputs.short_ref }}
ref: ${{ needs.meta_data.outputs.ref }}
tags: ${{ needs.meta_data.outputs.tags }}
labels: ${{ needs.meta_data.outputs.labels }}
platforms: "linux/amd64"