diff --git a/.github/workflows/__pr.yml b/.github/workflows/__pr.yml new file mode 100644 index 000000000..9050832a5 --- /dev/null +++ b/.github/workflows/__pr.yml @@ -0,0 +1,34 @@ +# Warning: This file is generated automatically, and should not be modified. +# Instead, please modify the template in the pr-checks directory and run: +# pr-checks/sync.sh +# to regenerate this file. + +name: PR Checks +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GO111MODULE: auto +on: + push: + branches: + - main + - releases/v* + pull_request: {} + merge_group: + types: + - checks_requested + schedule: + - cron: '0 5 * * *' + workflow_dispatch: + inputs: {} + workflow_call: + inputs: {} +defaults: + run: + shell: bash +jobs: + pr-checks: + name: Initial checks + permissions: + contents: read + security-events: read + uses: ./.github/workflows/pr-checks.yml diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 2ae059440..1c0255f49 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -2,13 +2,11 @@ name: PR Checks on: push: - pull_request: - merge_group: - types: [checks_requested] workflow_dispatch: + workflow_call: concurrency: - cancel-in-progress: ${{ github.event_name == 'pull_request' || false }} + cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_call' }} group: ${{ github.workflow }}-${{ github.ref }} defaults: diff --git a/pr-checks/sync.ts b/pr-checks/sync.ts index ae7fde50c..eeef57496 100755 --- a/pr-checks/sync.ts +++ b/pr-checks/sync.ts @@ -737,6 +737,45 @@ function main(): void { console.log(`Found ${checkFiles.length} check specification(s).`); + let allInputs: Record = {}; + + const initialChecksJob = workflowCall("Initial checks", "pr-checks"); + + const cron = new yaml.Scalar("0 5 * * *"); + cron.type = yaml.Scalar.QUOTE_SINGLE; + + const checkWorkflow = { + name: `PR Checks`, + env: { + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}", + GO111MODULE: "auto", + }, + on: { + push: { + branches: ["main", "releases/v*"], + }, + pull_request: {}, + merge_group: { + types: ["checks_requested"], + }, + schedule: [{ cron }], + workflow_dispatch: { + inputs: {}, + }, + workflow_call: { + inputs: {}, + }, + }, + defaults: { + run: { + shell: "bash", + }, + }, + jobs: { + "pr-checks": initialChecksJob, + }, + }; + const collections: Record< string, Array<{ @@ -781,9 +820,6 @@ function main(): void { extraGroupName += `-\${{inputs.${inputName}}}`; } - const cron = new yaml.Scalar("0 5 * * *"); - cron.type = yaml.Scalar.QUOTE_SINGLE; - const workflow = { name: `PR Check - ${checkSpecification.name}`, env: { @@ -826,6 +862,12 @@ function main(): void { writeYaml(outputPath, workflow); } + checkWorkflow.on.workflow_call.inputs = allInputs; + checkWorkflow.on.workflow_dispatch.inputs = allInputs; + + const mainOutputPath = path.join(OUTPUT_DIR, `__pr.yml`); + writeYaml(mainOutputPath, checkWorkflow); + // Write workflow files for collections. for (const collectionName of Object.keys(collections)) { const jobs: Record = {};