Skip to content

• 🛫 Release

• 🛫 Release #6

Workflow file for this run

name: • 🛫 Release
on:
workflow_dispatch:
permissions:
contents: write
issues: read
packages: write
pull-requests: read
# FIXME: This is a workaround for having workflow actions. See https://github.com/orgs/community/discussions/38659
id-token: write
jobs:
get-available-images-matrix:
uses: ./.github/workflows/__shared-get-available-images-matrix.yml
prepare-images-to-build:
needs: [get-available-images-matrix]
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
image: ${{ fromJson(needs.get-available-images-matrix.outputs.images-matrix) }}
steps:
- uses: actions/checkout@v4
- id: get-latest-tag-sha
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tags = await github.paginate(github.rest.repos.listTags, {
owner: context.repo.owner,
repo: context.repo.repo,
});
const tagFilter = '${{ matrix.image }}-';
const imageTags = tags.filter(tag => tag.name.startsWith(tagFilter));
// Sort tags regarding semver
imageTags.sort((a, b) => {
const aVersion = a.name.replace(tagFilter, '');
const bVersion = b.name.replace(tagFilter, '');
return bVersion.localeCompare(aVersion, undefined, { numeric: true });
});
core.setOutput('sha', imageTags.length ? imageTags[0].commit.sha : '');
- id: should-build-image
uses: ./.github/actions/should-build-image
with:
base-sha: ${{ steps.get-latest-tag-sha.outputs.sha }}
build-context: images/${{ matrix.image }}
- id: release
if: steps.should-build-image.outputs.should-build-image == 'true'
uses: release-drafter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
publish: true
config-name: release-config/${{ matrix.image }}-release-config.yml
- id: set-images-to-build
if: steps.should-build-image.outputs.should-build-image == 'true' && steps.release.outputs.tag_name != ''
run: |
BUILD_TAG=$(echo "${{ steps.release.outputs.tag_name }}" | sed -E "s/^${{ matrix.image }}-//")
BUILD_IMAGES='{"name":"${{ matrix.image }}","context":"images/${{ matrix.image }}", "dockerfile":"Dockerfile", "tag":"'$BUILD_TAG'", "platforms": ["linux/amd64","linux/arm64"]}'
echo "BUILD_IMAGES=$BUILD_IMAGES"
echo "images<<EOF" >> "$GITHUB_OUTPUT" && echo "$BUILD_IMAGES" >> "$GITHUB_OUTPUT" && echo "EOF" >> "$GITHUB_OUTPUT"
# FIXME: Set built images infos in file to be uploaded as artifacts, because github action does not handle job outputs for matrix
# https://github.com/orgs/community/discussions/26639
- if: steps.should-build-image.outputs.should-build-image == 'true'
uses: hoverkraft-tech/ci-github-common/actions/[email protected]
with:
value: ${{ steps.set-images-to-build.outputs.images }}
artifact-name: images-to-build
# FIXME: Download matrix ouputs from artifacts, because github action does not handle job outputs for matrix
# https://github.com/orgs/community/discussions/26639
# jscpd:ignore-start
get-images-to-build:
needs: prepare-images-to-build
runs-on: "ubuntu-latest"
outputs:
images: ${{ steps.get-matrix-outputs.outputs.result }}
steps:
- id: get-matrix-outputs
uses: hoverkraft-tech/ci-github-common/actions/[email protected]
with:
artifact-name: "images-to-build"
build-images:
needs: get-images-to-build
if: needs.get-images-to-build.outputs.images != '[]'
# FIXME: This is a workaround for having workflow actions. See https://github.com/orgs/community/discussions/38659
permissions:
id-token: write
contents: read
packages: write
issues: read
pull-requests: read
uses: hoverkraft-tech/ci-github-container/.github/workflows/[email protected]
with:
oci-registry: ${{ vars.OCI_REGISTRY }}
images: ${{ needs.get-images-to-build.outputs.images }}
secrets:
oci-registry-password: ${{ secrets.GITHUB_TOKEN }}
# jscpd:ignore-end