ci: trigger the PR’s synchronize checks on metadata update #48
Workflow file for this run
This file contains hidden or 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
| name: Test changed packages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: package-pipeline-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| discover: | |
| name: Discover packages | |
| uses: ./.github/workflows/discover-packages.yml | |
| with: | |
| base_sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before || '' }} | |
| head_sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | |
| build: | |
| name: Check and build packages | |
| needs: discover | |
| if: >- | |
| needs.discover.outputs.packages != '[]' && | |
| (github.event_name == 'pull_request' || github.ref == 'refs/heads/main') | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 4 | |
| matrix: | |
| package: ${{ fromJSON(needs.discover.outputs.packages) }} | |
| uses: ./.github/workflows/build-package.yml | |
| with: | |
| package: ${{ matrix.package }} | |
| required: | |
| name: Required package checks | |
| needs: [discover, build] | |
| if: ${{ always() }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Require successful package checks | |
| env: | |
| DISCOVERED_PACKAGES: ${{ needs.discover.outputs.packages }} | |
| DISCOVER_RESULT: ${{ needs.discover.result }} | |
| BUILD_RESULT: ${{ needs.build.result }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ "$DISCOVER_RESULT" != success ]]; then | |
| echo "Package discovery did not succeed: $DISCOVER_RESULT" >&2 | |
| exit 1 | |
| fi | |
| if [[ "$DISCOVERED_PACKAGES" == '[]' ]]; then | |
| echo 'No package changes require a build.' | |
| exit 0 | |
| fi | |
| if [[ "$BUILD_RESULT" != success ]]; then | |
| echo "Required package check did not succeed: build:$BUILD_RESULT" >&2 | |
| exit 1 | |
| fi | |
| publish: | |
| name: Publish packages | |
| needs: [discover, build] | |
| if: >- | |
| success() && github.event_name == 'push' && github.ref == 'refs/heads/main' && | |
| needs.build.result == 'success' && needs.discover.outputs.packages != '[]' | |
| uses: ./.github/workflows/publish-packages.yml | |
| permissions: | |
| actions: read | |
| contents: read | |
| secrets: inherit |