Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix Build Image tags #272

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Loading