Skip to content

Commit

Permalink
ci: invoke workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
levisingularity committed Jul 17, 2024
1 parent 5f82e3c commit 405171e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/check-repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ jobs:
- uses: actions/checkout@v4
outputs:
scheduled-repos: ${{ secrets.SCHEDULED_REPOS }}
gh-token: ${{ secrets.GH_TOKEN }}

lint:
runs-on: ubuntu-latest
uses: singnet/das/.github/workflows/invoke-workflow.yml@master
with:
workflow: ${{ matrix.repo.name }}
repo: ${{ matrix.repo.repo }}
token: ${{ needs.setup.outputs.gh-token }}
needs: setup
strategy:
matrix:
repo: ${{ fromJson(needs.outputs.scheduled-repos) }}
steps:
- name: Invoke workflow without inputs. Wait for result
uses: the-actions-org/workflow-dispatch@v4
with:
workflow: ${{ matrix.repo.name }}
repo: ${{ matrix.repo.repo }}
token: ${{ secrets.GH_TOKEN }}
42 changes: 42 additions & 0 deletions .github/workflows/invoke-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Invoke Workflow

on:
workflow_dispatch:
inputs:
repo:
description: "Repository name"
required: true
workflow:
description: "Workflow name"
required: true
ref:
description: "Git reference (branch or tag) to run the workflow on"
required: true
default: "master"

jobs:
invoke:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Invoke workflow without inputs. Wait for result
uses: actions/github-script@v6
with:
script: |
const workflow = '${{ github.event.inputs.workflow }}';
const repo = '${{ matrix.repo }}';
const ref = '${{ github.event.inputs.ref }}';
const token = '${{ secrets.GH_TOKEN }}';
const octokit = require('@octokit/rest')({
auth: token,
});
await octokit.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: repo,
workflow_id: workflow,
ref: ref,
});

0 comments on commit 405171e

Please sign in to comment.