Skip to content

Commit

Permalink
chore: Fix Build Image tags (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-pius authored Oct 21, 2024
1 parent 3fd13c5 commit a964656
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ 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: ""
Expand All @@ -18,31 +18,33 @@ permissions:
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: runtime-watcher
dockerfile: Dockerfile
context: ./runtime-watcher
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 a964656

Please sign in to comment.