-
Notifications
You must be signed in to change notification settings - Fork 23
115 lines (105 loc) · 4.38 KB
/
docker-images.yml
File metadata and controls
115 lines (105 loc) · 4.38 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
name: Build docker images
permissions:
contents: read
on:
workflow_call:
inputs:
push-command:
description: Push command to run (e.g., 'build-push-worker-image' or 'build-push-cli-image')
type: string
default: "build-push-worker-image"
lang:
description: SDK language to build the container for (only for worker images)
required: false
type: string
sdk-repo-ref:
description: Git ref of SDK repo to use to build (overrides "sdk-version")
required: false
type: string
sdk-repo-url:
description: URL of SDK repo to use to build (only used if "sdk-repo-ref" is provided)
required: false
type: string
sdk-version:
description: Version of SDK to use (ignored if "sdk-repo-ref" is provided, not used for CLI images)
required: false
type: string
docker-tag-ext:
description: Tag extension to use for the built image (only when using sdk-repo-ref)
required: false
type: string
do-push:
description: If set, push the built image to Docker Hub.
type: boolean
default: false
as-latest:
description: If set, tag the images as latest for the lang ('<lang>-latest').
type: boolean
default: false
omes-repo-path:
type: string
default: "temporalio/omes"
omes-repo-ref:
type: string
jobs:
publish-dockerhub:
name: Publish ${{ inputs.lang || 'CLI' }} to Docker Hub
runs-on: ubuntu-latest
if: inputs.do-push && !github.event.pull_request.head.repo.fork
timeout-minutes: 30
steps:
- name: Checkout omes repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.omes-repo-path }}
ref: ${{ inputs.omes-repo-ref || github.head_ref }}
submodules: true
fetch-depth: 0
- name: Checkout lang repo
if: ${{ inputs.sdk-repo-ref }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.sdk-repo-url }}
submodules: recursive
path: checked-out-sdk/
ref: ${{ inputs.sdk-repo-ref }}
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PAT }}
- name: Extract branch name
id: extract_branch
run: |
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | sed 's/\//-/g' | sed 's/[^a-zA-Z0-9._-]/-/g')
echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT
- name: Build and push to Docker Hub
env:
LANG: ${{ inputs.lang }}
SDK_VERSION: ${{ inputs.sdk-version || 'checked-out-sdk/' }}
BRANCH_TAG_COMPONENT: ${{ inputs.lang && format('{0}-{1}', inputs.lang, steps.extract_branch.outputs.branch_name) || format('cli-{0}', steps.extract_branch.outputs.branch_name) }}
IMAGE_TAG_ARGS: ${{ inputs.sdk-repo-ref && format('--image-tag {0}-{1} --image-tag {2}', inputs.lang, inputs.docker-tag-ext, inputs.lang && format('{0}-{1}', inputs.lang, steps.extract_branch.outputs.branch_name) || format('cli-{0}', steps.extract_branch.outputs.branch_name)) || format('--image-tag {0}', inputs.lang && format('{0}-{1}', inputs.lang, steps.extract_branch.outputs.branch_name) || format('cli-{0}', steps.extract_branch.outputs.branch_name)) }}
TAG_LATEST_ARGS: ${{ inputs.as-latest && '--tag-as-latest' || ''}}
LANG_ARGS: ${{ inputs.lang && format('--language {0}', inputs.lang) || '' }}
VERSION_ARGS: ${{ inputs.sdk-version && format('--version {0}', inputs.sdk-version) || '' }}
PUSH_COMMAND: ${{ inputs.push-command }}
run: |
go run ./cmd/dev "$PUSH_COMMAND" \
--platform linux/amd64,linux/arm64 \
--repo-prefix temporaliotest \
$LANG_ARGS \
$VERSION_ARGS \
$IMAGE_TAG_ARGS \
$TAG_LATEST_ARGS
- name: 🐳 Docker Hub image tag
env:
LANG: ${{ inputs.lang || 'CLI' }}
run: |
echo "::notice title=🐳 Docker Hub image published for $LANG::Check temporaliotest/omes tags"