Skip to content

Commit a5411f6

Browse files
committed
Switch from reusable workflow to workflow_dispatch events
Main reason being that, when using reusable workflow the workflow is literally embed into the called one and that makes badges and integrations to stop working. We want the "Test and publish" workflow to be executed standalone, hence, invoking it via workflow_dispatch.
1 parent b54f61c commit a5411f6

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

.github/workflows/test_buildx_and_publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test and publish
1+
name: Test, build and publish
22

33
on:
44
push:
@@ -84,7 +84,7 @@ jobs:
8484
password: ${{ secrets.GITHUB_TOKEN }}
8585

8686
# https://github.com/docker/build-push-action#multi-platform-image
87-
- name: Build and push to Docker Hub and Github registries
87+
- name: Build and publish to Docker Hub and Github registries
8888
uses: docker/build-push-action@v3
8989
with:
9090
context: .

.github/workflows/trigger_new_builds.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Trigger new builds
1+
name: Conditional new builds
22

33
# If any of the criteria happens, they set the trigger_build
44
# output variable to 'true' and the rebuild will happen.
@@ -19,6 +19,7 @@ jobs:
1919

2020
outputs:
2121
trigger_build: ${{ steps.calculate.outputs.result }}
22+
docker_tag: ${{ steps.calculate.outputs.tag }}
2223

2324
steps:
2425

@@ -35,13 +36,14 @@ jobs:
3536
tag=${{ env.GITHUB_REF_SLUG }}
3637
fi
3738
echo "LOG: docker tag: $tag"
39+
echo "tag=$tag" >> $GITHUB_OUTPUT
3840
3941
# Extract the timezonedb version from the image.
4042
current=$(docker run -t --rm moodlehq/moodle-php-apache:$tag php -r 'echo timezone_version_get();')
4143
echo "LOG: current: $current"
4244
4345
# Look for the latest tag available @ https://github.com/php/pecl-datetime-timezonedb
44-
latest=$(curl -s "https://api.github.com/repos/php/pecl-datetime-timezonedb/tags" | jq -r '.[0].name')
46+
latest=$(curl -s "https://api.github.com/repos/php/pecl-datetime-timezonedb/tags" | jq -r '.[0].name' || true)
4547
echo "LOG: latest: $latest"
4648
4749
# Compare the versions (digits only), if current < latest, then we need to rebuild.
@@ -56,13 +58,12 @@ jobs:
5658
# if any of them has ended with the "trigger_build" output set, then
5759
# will set its own (final) trigger_build output to 'true'.
5860
evaluate-results:
59-
# Completely avoid forks and pull requests to try this job.
60-
if: github.repository_owner == 'moodlehq' && contains(fromJson('["workflow_dispatch"]'), github.event_name)
6161
runs-on: ubuntu-latest
6262
needs: [datetimedb-new-release]
6363

6464
outputs:
6565
trigger_build: ${{ steps.evaluate.outputs.result }}
66+
docker_tag: ${{ needs.datetimedb-new-release.outputs.docker_tag }}
6667

6768
steps:
6869

@@ -80,8 +81,12 @@ jobs:
8081
build:
8182
# Only if the final workflow.outputs.trigger_build from evaluate job has decided to build.
8283
if: needs.evaluate-results.outputs.trigger_build == 'true'
84+
runs-on: ubuntu-latest
8385
needs: [evaluate-results]
8486

85-
# Launch the build job (as reusable workflow).
86-
uses: ./.github/workflows/test_buildx_and_publish.yml
87-
secrets: inherit
87+
steps:
88+
89+
- name: Launch the Test and publish workflow (${{ needs.evaluate-results.outputs.docker_tag }})
90+
uses: benc-uk/workflow-dispatch@v1
91+
with:
92+
workflow: Test, build and publish

0 commit comments

Comments
 (0)