Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update feature/mergeable/manual-workflows@RedEyeMods/.github #121

Merged
1 change: 1 addition & 0 deletions .github/workflows/install-mergeable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 22 additions & 19 deletions .github/workflows/update-all-mergeables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
11 changes: 11 additions & 0 deletions .github/workflows/update-mergeables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading