Skip to content

Commit 226f9b3

Browse files
committed
REMOVE: Add ability to publish a PR to docker hub
1 parent a1e0fc1 commit 226f9b3

1 file changed

Lines changed: 43 additions & 6 deletions

File tree

.github/workflows/sync_service_dockerhub_image.yml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ on:
1919
inputs:
2020
release_tag:
2121
description: 'The @core/sync-service@... tag to run the workflow for (e.g. @core/sync-service@1.2.10)'
22-
required: true
22+
required: false
23+
type: string
24+
custom_ref:
25+
description: 'Git ref to build from (branch, tag, or commit SHA). Use with custom_tag.'
26+
required: false
27+
type: string
28+
custom_tag:
29+
description: 'Docker Hub tag to publish as (e.g. subqueries-alpha). Use with custom_ref.'
30+
required: false
2331
type: string
2432

2533
env:
@@ -33,6 +41,8 @@ jobs:
3341
outputs:
3442
git_ref: ${{ steps.git_ref.outputs.git_ref }}
3543
is_release: ${{ steps.git_ref.outputs.is_release }}
44+
is_custom: ${{ steps.git_ref.outputs.is_custom }}
45+
custom_tag: ${{ steps.git_ref.outputs.custom_tag }}
3646
short_commit_sha: ${{ steps.vars.outputs.short_commit_sha }}
3747
electric_version: ${{ steps.vars.outputs.electric_version }}
3848

@@ -41,22 +51,41 @@ jobs:
4151
id: git_ref
4252
env:
4353
INPUT_RELEASE_TAG: ${{ inputs.release_tag }}
54+
INPUT_CUSTOM_REF: ${{ inputs.custom_ref }}
55+
INPUT_CUSTOM_TAG: ${{ inputs.custom_tag }}
4456
EVENT_RELEASE_TAG: ${{ github.event.release.tag_name }}
4557
COMMIT_SHA: ${{ github.sha }}
4658
run: |
47-
if [ -n "$INPUT_RELEASE_TAG" ]; then
59+
if [ -n "$INPUT_CUSTOM_REF" ]; then
60+
if [ -z "$INPUT_CUSTOM_TAG" ]; then
61+
echo "::error::custom_ref requires custom_tag to be set"
62+
exit 1
63+
fi
64+
ref="$INPUT_CUSTOM_REF"
65+
is_release=false
66+
is_custom=true
67+
custom_tag="$INPUT_CUSTOM_TAG"
68+
elif [ -n "$INPUT_RELEASE_TAG" ]; then
4869
ref="refs/tags/$INPUT_RELEASE_TAG"
4970
is_release=true
71+
is_custom=false
72+
custom_tag=""
5073
elif [ -n "$EVENT_RELEASE_TAG" ]; then
5174
ref="refs/tags/$EVENT_RELEASE_TAG"
5275
is_release=true
76+
is_custom=false
77+
custom_tag=""
5378
else
5479
ref="$COMMIT_SHA"
5580
is_release=false
81+
is_custom=false
82+
custom_tag=""
5683
fi
5784
5885
echo "git_ref=$ref" >> $GITHUB_OUTPUT
5986
echo "is_release=$is_release" >> $GITHUB_OUTPUT
87+
echo "is_custom=$is_custom" >> $GITHUB_OUTPUT
88+
echo "custom_tag=$custom_tag" >> $GITHUB_OUTPUT
6089
6190
- uses: actions/checkout@v4
6291
with:
@@ -83,9 +112,13 @@ jobs:
83112
git rev-parse --short HEAD
84113
)" >> $GITHUB_OUTPUT
85114
86-
echo "electric_version=$(
87-
git describe --abbrev=7 --tags --always --first-parent --match '@core/sync-service@*' | sed -En 's|^@core/sync-service@||p'
88-
)" >> $GITHUB_OUTPUT
115+
if [ "${{ steps.git_ref.outputs.is_custom }}" = "true" ]; then
116+
echo "electric_version=${{ steps.git_ref.outputs.custom_tag }}" >> $GITHUB_OUTPUT
117+
else
118+
echo "electric_version=$(
119+
git describe --abbrev=7 --tags --always --first-parent --match '@core/sync-service@*' | sed -En 's|^@core/sync-service@||p'
120+
)" >> $GITHUB_OUTPUT
121+
fi
89122
90123
build_and_push_image:
91124
strategy:
@@ -160,7 +193,11 @@ jobs:
160193

161194
- name: Derive image tags from the GitHub Actions event
162195
run: |
163-
if [ "${{ needs.derive_build_vars.outputs.is_release }}" = "true" ]; then
196+
if [ "${{ needs.derive_build_vars.outputs.is_custom }}" = "true" ]; then
197+
# A custom build publishes only the requested tag
198+
echo "ELECTRIC_TAGS=-t $DOCKERHUB_REPO:${{ needs.derive_build_vars.outputs.custom_tag }}" >> $GITHUB_ENV
199+
echo "ELECTRIC_CANARY_TAGS=" >> $GITHUB_ENV
200+
elif [ "${{ needs.derive_build_vars.outputs.is_release }}" = "true" ]; then
164201
# A release triggers official release image publishing
165202
echo "ELECTRIC_TAGS=-t $DOCKERHUB_REPO:latest -t $DOCKERHUB_REPO:${{ needs.derive_build_vars.outputs.electric_version }}" >> $GITHUB_ENV
166203
echo "ELECTRIC_CANARY_TAGS=" >> $GITHUB_ENV

0 commit comments

Comments
 (0)