diff --git a/.github/workflows/test_buildx_and_publish.yml b/.github/workflows/test_buildx_and_publish.yml index 8e262a7..1a6b0a8 100644 --- a/.github/workflows/test_buildx_and_publish.yml +++ b/.github/workflows/test_buildx_and_publish.yml @@ -1,4 +1,4 @@ -name: Test and publish +name: Test, build and publish on: push: @@ -84,7 +84,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} # https://github.com/docker/build-push-action#multi-platform-image - - name: Build and push to Docker Hub and Github registries + - name: Build and publish to Docker Hub and Github registries uses: docker/build-push-action@v3 with: context: . diff --git a/.github/workflows/trigger_new_builds.yml b/.github/workflows/trigger_new_builds.yml index 9fcea93..42d75b4 100644 --- a/.github/workflows/trigger_new_builds.yml +++ b/.github/workflows/trigger_new_builds.yml @@ -1,4 +1,4 @@ -name: Trigger new builds +name: Conditional new builds # If any of the criteria happens, they set the trigger_build # output variable to 'true' and the rebuild will happen. @@ -19,6 +19,7 @@ jobs: outputs: trigger_build: ${{ steps.calculate.outputs.result }} + docker_tag: ${{ steps.calculate.outputs.tag }} steps: @@ -35,13 +36,14 @@ jobs: tag=${{ env.GITHUB_REF_SLUG }} fi echo "LOG: docker tag: $tag" + echo "tag=$tag" >> $GITHUB_OUTPUT # Extract the timezonedb version from the image. current=$(docker run -t --rm moodlehq/moodle-php-apache:$tag php -r 'echo timezone_version_get();') echo "LOG: current: $current" # Look for the latest tag available @ https://github.com/php/pecl-datetime-timezonedb - latest=$(curl -s "https://api.github.com/repos/php/pecl-datetime-timezonedb/tags" | jq -r '.[0].name') + latest=$(curl -s "https://api.github.com/repos/php/pecl-datetime-timezonedb/tags" | jq -r '.[0].name' || true) echo "LOG: latest: $latest" # Compare the versions (digits only), if current < latest, then we need to rebuild. @@ -56,13 +58,12 @@ jobs: # if any of them has ended with the "trigger_build" output set, then # will set its own (final) trigger_build output to 'true'. evaluate-results: - # Completely avoid forks and pull requests to try this job. - if: github.repository_owner == 'moodlehq' && contains(fromJson('["workflow_dispatch"]'), github.event_name) runs-on: ubuntu-latest needs: [datetimedb-new-release] outputs: trigger_build: ${{ steps.evaluate.outputs.result }} + docker_tag: ${{ needs.datetimedb-new-release.outputs.docker_tag }} steps: @@ -80,8 +81,12 @@ jobs: build: # Only if the final workflow.outputs.trigger_build from evaluate job has decided to build. if: needs.evaluate-results.outputs.trigger_build == 'true' + runs-on: ubuntu-latest needs: [evaluate-results] - # Launch the build job (as reusable workflow). - uses: ./.github/workflows/test_buildx_and_publish.yml - secrets: inherit + steps: + + - name: Launch the Test and publish workflow (${{ needs.evaluate-results.outputs.docker_tag }}) + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Test, build and publish