@@ -3,6 +3,7 @@ name: Check Certificates
33
44# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
55on :
6+ create :
67 push :
78 paths :
89 - " .github/workflows/check-certificates.ya?ml"
2021 EXPIRATION_WARNING_PERIOD : 30
2122
2223jobs :
24+ run-determination :
25+ runs-on : ubuntu-latest
26+ outputs :
27+ result : ${{ steps.determination.outputs.result }}
28+ permissions : {}
29+ steps :
30+ - name : Determine if the rest of the workflow should run
31+ id : determination
32+ run : |
33+ RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
34+ REPO_SLUG="arduino/arduino-lint"
35+ if [[
36+ (
37+ # Only run on branch creation when it is a release branch.
38+ # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
39+ "${{ github.event_name }}" != "create" ||
40+ "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
41+ ) &&
42+ (
43+ # Only run when the workflow will have access to the certificate secrets.
44+ # This could be done via a GitHub Actions workflow conditional, but makes more sense to do it here as well.
45+ (
46+ "${{ github.event_name }}" != "pull_request" &&
47+ "${{ github.repository }}" == "$REPO_SLUG"
48+ ) ||
49+ (
50+ "${{ github.event_name }}" == "pull_request" &&
51+ "${{ github.event.pull_request.head.repo.full_name }}" == "$REPO_SLUG"
52+ )
53+ )
54+ ]]; then
55+ # Run the other jobs.
56+ RESULT="true"
57+ else
58+ # There is no need to run the other jobs.
59+ RESULT="false"
60+ fi
61+
62+ echo "result=$RESULT" >> $GITHUB_OUTPUT
63+
2364 check-certificates :
2465 name : ${{ matrix.certificate.identifier }}
25- # Only run when the workflow will have access to the certificate secrets.
26- if : >
27- (github.event_name != 'pull_request' && github.repository == 'arduino/arduino-lint') ||
28- (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'arduino/arduino-lint')
66+ needs : run-determination
67+ if : needs.run-determination.outputs.result == 'true'
2968 runs-on : ubuntu-latest
3069 permissions : {}
3170 strategy :
0 commit comments