Skip to content

Fossify event dispatcher #13

Fossify event dispatcher

Fossify event dispatcher #13

name: Fossify event dispatcher
on:
workflow_dispatch:
inputs:
task:
description: "What to run"
required: true
default: "prepare-release"
type: choice
options:
- "prepare-release"
- "update-lint-baselines"
- "update-commons"
repository:
description: "Trigger a specific repo or all"
required: true
default: "all"
type: choice
options:
- "all"
- "FossifyOrg/Calculator"
- "FossifyOrg/Calendar"
- "FossifyOrg/Camera"
- "FossifyOrg/Clock"
- "FossifyOrg/Contacts"
- "FossifyOrg/Documents"
- "FossifyOrg/File-Manager"
- "FossifyOrg/Gallery"
- "FossifyOrg/Keyboard"
- "FossifyOrg/Launcher"
- "FossifyOrg/Messages"
- "FossifyOrg/Music-Player"
- "FossifyOrg/Notes"
- "FossifyOrg/Paint"
- "FossifyOrg/Phone"
- "FossifyOrg/Thank-You"
- "FossifyOrg/Voice-Recorder"
workflow_call:
inputs:
task:
required: true
type: string
repository:
required: true
type: string
concurrency:
group: "manual-dispatcher-${{ inputs.task || github.event.inputs.task }}-${{ inputs.repository || github.event.inputs.repository }}"
cancel-in-progress: true
jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1
with:
egress-policy: audit
- id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const repos = [
'FossifyOrg/Calculator',
'FossifyOrg/Calendar',
'FossifyOrg/Camera',
'FossifyOrg/Clock',
'FossifyOrg/Contacts',
'FossifyOrg/Documents',
'FossifyOrg/File-Manager',
'FossifyOrg/Gallery',
'FossifyOrg/Keyboard',
'FossifyOrg/Launcher',
'FossifyOrg/Messages',
'FossifyOrg/Music-Player',
'FossifyOrg/Notes',
'FossifyOrg/Paint',
'FossifyOrg/Phone',
'FossifyOrg/Thank-You',
'FossifyOrg/Voice-Recorder',
];
const selectedRepo = '${{ inputs.repository || github.event.inputs.repository }}';
const task = '${{ inputs.task || github.event.inputs.task }}';
let reposToProcess = [];
if (selectedRepo === 'all') {
reposToProcess = repos;
console.log(`Manual ${task} for all repositories (${repos.length} repos):`, reposToProcess);
} else {
reposToProcess = [selectedRepo];
console.log(`Manual ${task} for: ${selectedRepo}`);
}
for (const repoPath of reposToProcess) {
console.log(`Dispatching "${task}" to ${repoPath}`);
const [owner, repo] = repoPath.split('/');
try {
await github.rest.repos.createDispatchEvent({
owner,
repo,
event_type: task,
});
} catch (e) {
console.warn(`${repoPath} failed: ${e.message}`);
}
await new Promise(r => setTimeout(r, 1000));
}