Skip to content

Commit fc28eb8

Browse files
authored
fix: Use workflow call to trigger image build during release (#254)
<!-- Thank you for your contribution. Before you submit the pull request: 1. Follow contributing guidelines, templates, the recommended Git workflow, and any related documentation. 2. Read and submit the required Contributor Licence Agreements (https://github.com/kyma-project/community/blob/main/CONTRIBUTING.md#agreements-and-licenses). 3. Test your changes and attach their results to the pull request. 4. Update the relevant documentation. If the pull request requires a decision, follow the [decision-making process](https://github.com/kyma-project/community/blob/main/governance.md) and replace the PR template with the [decision record template](https://github.com/kyma-project/community/blob/main/.github/ISSUE_TEMPLATE/decision-record.md). --> **Description** Due to the [restriction](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow#triggering-a-workflow-from-a-workflow) that use default `GITHUB_TOKEN` to push tags will not trigger related workflow (`build-image.yml`), this PR refactored the create-release workflow to use build-image specifically. Tested in my fork: https://github.com/ruanxin/template-operator/actions/runs/10705244987 **Related issue(s)** <!-- If you refer to a particular issue, provide its number. For example, `Resolves #123`, `Fixes #43`, or `See also #33`. -->
1 parent 9bbe3a0 commit fc28eb8

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

.github/workflows/build-template-operator.yml renamed to .github/workflows/build-image.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ on:
44
push:
55
branches:
66
- main # This will get tagged with `latest` and `v{{DATE}}-{{COMMIT_HASH_SHORT}}`
7-
tags:
8-
- '[0-9]+.[0-9]+.[0-9]+'
9-
- '[0-9]+.[0-9]+.[0-9]+-*'
7+
workflow_call:
8+
inputs:
9+
tag:
10+
description: 'Additional tag for built images'
11+
required: false
12+
type: string
13+
default: ""
1014
pull_request_target:
1115
types: [ opened, edited, synchronize, reopened, ready_for_review ]
1216

@@ -25,8 +29,8 @@ jobs:
2529
- name: Get the latest tag
2630
id: get_tag
2731
run: |
28-
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
29-
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
32+
if [[ "${{ inputs.tag }}" != "" ]]; then
33+
echo "tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT
3034
elif [[ "${{ github.event_name }}" == "push" ]]; then
3135
echo "tag=latest" >> $GITHUB_OUTPUT
3236
fi

.github/workflows/create-release.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,10 @@ jobs:
5050
run: |
5151
RELEASE_ID=$(./scripts/release/draft_release.sh ${{ github.event.inputs.name }})
5252
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
53-
- name: Create lightweight tag
53+
- name: Create tag
5454
run: |
5555
git tag ${{ github.event.inputs.name }}
5656
git push origin ${{ github.event.inputs.name }} --tags
57-
- name: Wait for the Docker image
58-
timeout-minutes: 20
59-
env:
60-
ITERATIONS: 40
61-
SLEEP_SECONDS: 30
62-
run: ./scripts/release/wait_for_image.sh ${{ env.IMAGE_REPO }}:${{ github.event.inputs.name }} $ITERATIONS $SLEEP_SECONDS
6357
- name: Create release assets
6458
id: create-assets
6559
env:
@@ -68,7 +62,11 @@ jobs:
6862
run: ./scripts/release/upload_assets.sh
6963
outputs:
7064
release_id: ${{ steps.draft-release.outputs.release_id }}
71-
65+
builds:
66+
needs: draft-release
67+
uses: ./.github/workflows/build-image.yml
68+
with:
69+
tag: "${{ github.event.inputs.name }}"
7270
publish-release:
7371
name: Publish release
7472
needs: [validate-head-status, draft-release]
@@ -78,6 +76,12 @@ jobs:
7876
uses: actions/checkout@v4
7977
with:
8078
fetch-depth: 0
79+
- name: Wait for the Docker image
80+
timeout-minutes: 20
81+
env:
82+
ITERATIONS: 40
83+
SLEEP_SECONDS: 30
84+
run: ./scripts/release/wait_for_image.sh ${{ env.IMAGE_REPO }}:${{ github.event.inputs.name }} $ITERATIONS $SLEEP_SECONDS
8185
- name: Publish release
8286
env:
8387
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)