Skip to content

Commit

Permalink
chore: Fix Build Image tags (#272)
Browse files Browse the repository at this point in the history
<!-- 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.
-->

**Description**

Changes proposed in this pull request:

- fixes the provided custom tags

`pull_request_target` makes this PR use the old image build func here.
Didn't test separately again because it has been tested as part of:
kyma-project/lifecycle-manager#1970

**Related issue(s)**
<!-- If you refer to a particular issue, provide its number. For
example, `Resolves #123`, `Fixes #43`, or `See also #33`. -->

- partially closes
https://github.com/orgs/kyma-project/projects/30/views/13?pane=issue&itemId=83441848
  • Loading branch information
c-pius authored Oct 21, 2024
1 parent 0680468 commit 6e81d0e
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
name: build-template-operator
name: Build Image

on:
push:
branches:
- main # This will get tagged with `latest` and `v{{DATE}}-{{COMMIT_HASH_SHORT}}`
- main
workflow_call:
inputs:
tag:
description: 'Additional tag for built images'
description: 'Additional tag for built image'
required: false
type: string
default: ""
pull_request_target:
types: [ opened, edited, synchronize, reopened, ready_for_review ]

permissions:
id-token: write # This is required for requesting the JWT token
contents: read # This is required for actions/checkout

jobs:
compute-tag:
get-custom-tags:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get_tag.outputs.tag }}
tags: ${{ steps.get_custom_tags.outputs.tags }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get the latest tag
id: get_tag
- name: Get tags
id: get_custom_tags
run: |
if [[ "${{ inputs.tag }}" != "" ]]; then
echo "tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT
else
{
echo 'tag<<TAGS'
echo 'PR-${{ github.event.pull_request.number }}'
echo '${{ github.event.pull_request.head.sha }}'
echo 'TAGS'
} >> "$GITHUB_OUTPUT"
tags=""
if [[ "${{ github.event_name }}" == "push" ]]; then
tags="latest"
elif [[ "${{ github.event_name }}" == "workflow_call" ]]; then
tags="${{ inputs.tag }}"
elif [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
tags="${{ github.event.pull_request.head.sha }}"
fi
echo "Using custom tags: '$tags'"
echo "tags=$tags" >> $GITHUB_OUTPUT
build-image:
needs: compute-tag
needs: get-custom-tags
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: template-operator
dockerfile: Dockerfile
context: .
tags: ${{ needs.compute-tag.outputs.tag }}
# tags are additional tags that will be added to the image on top of the default ones
# default tags are documented here: https://github.com/kyma-project/test-infra/tree/main/cmd/image-builder#default-tags
tags: ${{ needs.get-custom-tags.outputs.tags }}

0 comments on commit 6e81d0e

Please sign in to comment.