diff --git a/.github/workflows/install-mergeable.yml b/.github/workflows/install-mergeable.yml index 9730e89..5c06942 100644 --- a/.github/workflows/install-mergeable.yml +++ b/.github/workflows/install-mergeable.yml @@ -109,6 +109,7 @@ jobs: uses: actions/checkout@v4 with: repository: ${{ needs.get-target-data.outputs.target-repo }} + ref: ${{ github.event.repository.default_branch }} - name: Import GPG key uses: crazy-max/ghaction-import-gpg@v6 diff --git a/.github/workflows/update-all-mergeables.yml b/.github/workflows/update-all-mergeables.yml index 789b4e4..29e648d 100644 --- a/.github/workflows/update-all-mergeables.yml +++ b/.github/workflows/update-all-mergeables.yml @@ -8,6 +8,16 @@ on: description: Mergeable id to update in the form of (feature/mergeable/...@RedEyeMods/.github). required: true jobs: + inputs-report: + name: Summary Report + runs-on: ubuntu-latest + steps: + - name: Script + uses: actions/github-script@v7 + with: + script: | + core.notice("Initiating organization-wide update of '${{ inputs.filter-mergeable }}'."); + get-repositories: name: Organization Repositories runs-on: ubuntu-latest @@ -39,37 +49,30 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - sparse-checkout: .github repository: ${{ matrix.target-repo }} + ref: ${{ github.event.repository.default_branch }} - - name: Trigger workflow if it exists + - name: Trigger workflows id: mergeables uses: actions/github-script@v7 with: github-token: ${{ secrets.ORG_PAT }} script: | - const nameSplit = ("${{ matrix.target-repo }}").split('/'); - const repoWorkflowsRequest = await github.rest.actions.listRepoWorkflows({ - owner: nameSplit[0], - repo: nameSplit[1] - }); - if (repoWorkflowsRequest.status != 200) - throw new Exception("Bad response: " + repoWorkflowsRequest.status); - - const targetWorkflow = 'update-mergeables.yml'; - const repoWorkflows = repoWorkflowsRequest.data.workflows; - - if (repoWorkflows.filter(workflow => workflow.path.endsWith(targetWorkflow)).length != 1) { - core.warning(`Repo ${nameSplit[0]}/${nameSplit[1]} doesn't contain ${targetWorkflow}!`); + const fs = require('fs'); + if (!fs.existsSync('.github/.mergeables')) { + core.warning("${{ matrix.target-repo }} doesn't contain a .github/.mergeables"); return; } + const homeNameSplit = ("${{ github.repository }}").split('/'); + github.rest.actions.createWorkflowDispatch({ - owner: nameSplit[0], - repo: nameSplit[1], - workflow_id: targetWorkflow, + owner: homeNameSplit[0], + repo: homeNameSplit[1], + workflow_id: 'update-mergeables.yml', ref: context.payload.repository.default_branch, inputs: { - "filter-mergeable": '${{ inputs.filter-mergeable }}' + "filter-mergeable": '${{ inputs.filter-mergeable }}', + "target-repo": '${{ matrix.target-repo }}' } }); result-encoding: json diff --git a/.github/workflows/update-mergeables.yml b/.github/workflows/update-mergeables.yml index 3d3bdab..2cb9029 100644 --- a/.github/workflows/update-mergeables.yml +++ b/.github/workflows/update-mergeables.yml @@ -13,6 +13,16 @@ on: description: Filter matrix entries to contain this text. required: false jobs: + inputs-report: + name: Summary Report + runs-on: ubuntu-latest + steps: + - name: Script + uses: actions/github-script@v7 + with: + script: | + core.notice("Initiating update of '${{ inputs.filter-mergeable }}' @ '${{ inputs.target-repo }}'."); + input-sanitation: name: Input Sanitation runs-on: ubuntu-latest @@ -63,6 +73,7 @@ jobs: update-matrix: name: Update Matrix needs: [ input-sanitation, obtain-mergeables ] + if: needs.input-sanitation.outputs.target-repo != '' runs-on: ubuntu-latest strategy: matrix: