-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Fix build on new upstream detection
Push of new tag from workflow did not trigger the push event on the seperate build workflow. So we collapse it to one workflow, where we only build on new upstream releases or if a users forces it.
- Loading branch information
Showing
2 changed files
with
41 additions
and
36 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
name: Detect new upstream release | ||
name: Detect and build new upstream based release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
force_build: | ||
description: "Build even though there is no new upstream release." | ||
required: true | ||
default: false | ||
type: boolean | ||
|
||
push: | ||
tags: ["*"] | ||
|
||
schedule: | ||
# https://crontab.guru/#0_7_*_*_1-5 | ||
- cron: "0 7 * * 1-5" | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
trigger-from-upstream: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# https://github.com/actions/checkout/?tab=readme-ov-file#usage | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
# fetch-tags: true # Does not work for some reason, so we we use fetch-depth: 0 | ||
|
||
- name: Pipeline debug | ||
if: vars.DEBUG == 'true' | ||
if: vars.DEBUG == 'true' # https://github.com/fut-infrastructure/ig-publisher/settings/variables/actions | ||
run: | | ||
echo "Upstream output: ${{ steps.upstream.outputs.upstream_version }}" | ||
echo "Files:" | ||
ls -lav | ||
echo "Git info:" | ||
|
@@ -27,20 +42,27 @@ jobs: | |
echo "Tags:" | ||
git tag --sort=committerdate | ||
echo "SemVer tags:" | ||
git tag --sort=committerdate | grep -E '[0-9]' | ||
git tag --sort=committerdate | grep -Eo '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}' | ||
- name: Get the latest upstream release | ||
id: upstream | ||
run: | | ||
# https://docs.github.com/en/rest/releases/releases?#get-the-latest-release | ||
upstream_version=$(curl -s https://api.github.com/repos/HL7/fhir-ig-publisher/releases/latest | jq -r '.tag_name') | ||
# https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs | ||
echo "upstream_version=$upstream_version" >> $GITHUB_OUTPUT | ||
echo "Found upstream release: \"$upstream_version\"" | ||
- name: Get the latest FUT release | ||
id: fut | ||
run: | | ||
fut_version=$(git tag --sort=committerdate | grep -E '[0-9]' | tail -1 | sed 's/\\n/\n/g') | ||
echo "Latest SemVer tag: $(git tag --sort=committerdate | grep -E '[0-9]' | tail -1)" | ||
# https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---sortltkeygt | ||
# https://remarkablemark.org/blog/2023/04/15/how-to-grep-for-semver/ | ||
fut_version=$(git tag --sort=committerdate \ | ||
| grep -Eo '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}' \ | ||
| tail -1 \ | ||
| sed 's/\\n//g') # Remove any newlines. | ||
echo "Latest SemVer tag: $fut_version" | ||
echo "fut_version=$fut_version" >> $GITHUB_OUTPUT | ||
echo "Found FUT release: \"$fut_version\"" | ||
|
@@ -51,3 +73,16 @@ jobs: | |
echo "FUT output: ${{ steps.fut.outputs.fut_version }}" | ||
git tag ${{ steps.upstream.outputs.upstream_version }} | ||
git push origin ${{ steps.upstream.outputs.upstream_version }} | ||
- name: build | ||
if: >- | ||
(steps.upstream.outputs.upstream_version != steps.fut.outputs.fut_version) || | ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.force_build == 'true') | ||
uses: aevea/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
image: ig-publisher | ||
tag_with_latest: true | ||
tag: ${{ steps.fut.outputs.fut_version }} | ||
extra_args: ${{ format('--build-arg IG_PUB_VERSION={0}', steps.fut.outputs.fut_version) }} |