multiple dependent repos fixes #49
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: CI-Scripts | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| build-dependent: | ||
| description: 'Should build dependent repositories?' | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| push: | ||
| branches: | ||
| - 'master' | ||
| schedule: | ||
| - cron: "42 23 31 12 *" | ||
| jobs: | ||
| create-dependent-matrix: | ||
| runs-on: ubuntu-latest | ||
| name: 'Find dependent repositories' | ||
| outputs: | ||
| matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/[email protected] | ||
| - name: Create dependent build matrix (or empty) | ||
| id: set-matrix | ||
| shell: bash | ||
| run: | | ||
| BUILD_DEPENDENT="${{ inputs.build-dependent || github.event.inputs.build-dependent || 'false' }}" | ||
| EVENT="${{ github.event_name }}" | ||
| if [[ "$EVENT" != "push" && "$EVENT" != "schedule" && "$EVENT" != "workflow_dispatch" && "$EVENT" != "workflow_call" ]]; then | ||
| echo "Dependent builds: disabled: unsupported event=$EVENT" | ||
| echo 'matrix={"include":[{"noop":true}]}' >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| if [[ ( "$EVENT" == "workflow_dispatch" || "$EVENT" == "workflow_call" ) && "$BUILD_DEPENDENT" != "true" ]]; then | ||
| echo "Dependent builds: disabled: build-dependent input is false" | ||
| echo 'matrix={"include":[{"noop":true}]}' >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| if [[ ! -f ./.github/dependent-repositories.txt ]]; then | ||
| echo "Dependent builds: disabled: dependent-repositories.txt not found" | ||
| echo 'matrix={"include":[{"noop":true}]}' >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| count="$(jq -e '.include | if type=="array" then length else error(".include must be an array") end' ./.github/dependent-repositories.txt)" | ||
| if [[ "$count" == "0" ]]; then | ||
| echo "Dependent builds: disabled: dependent-repositories.txt empty" | ||
| echo 'matrix={"include":[{"noop":true}]}' >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| matrix="$(jq -c '.' ./.github/dependent-repositories.txt)" | ||
| echo "Dependent builds: enabled" | ||
| echo "matrix=$matrix" >> "$GITHUB_OUTPUT" | ||
| build-dependent: | ||
| needs: [create-dependent-matrix] | ||
| runs-on: ubuntu-latest | ||
| name: 'Build dependent' | ||
| if: ${{ matrix.noop != true }} | ||
| strategy: | ||
| matrix: ${{fromJson(needs.create-dependent-matrix.outputs.matrix)}} | ||
| steps: | ||
| - name: Start ${{ matrix.repository }} build | ||
| uses: benc-uk/[email protected] | ||
| with: | ||
| workflow: Nightly | ||
| repo: ${{ matrix.repository }} | ||
| ref: ${{ matrix.branch }} | ||
| token: ${{ secrets.WORKFLOW_ACCESS_TOKEN }} | ||
| inputs: '{ "build-dependent": "${{ matrix.build-dependent }}" }' | ||