Files
oxc-project__oxc/.github/workflows/ecosystem-ci.yml
Cameron f6f0fbf5d9 ci(ecosystem): share label trigger for app ci (#22906)
This is stacked on #22905.

The first PR moved Oxfmt ecosystem CI to a label-triggered workflow.
This follow-up keeps that approach, but avoids having one workflow file
per app. Instead, the Oxfmt-specific workflow is renamed to a shared
ecosystem CI dispatcher that handles both trigger labels:

- `run-oxlint-ecosystem-ci` dispatches `oxlint-ci.yml`
- `run-oxfmt-ecosystem-ci` dispatches `oxfmt-ci.yml`

The release-apps workflow now adds both labels to the generated release
PR, so Oxlint and Oxfmt take the same path: create or update the
tracking comment, dispatch the matching workflow in `oxc-ecosystem-ci`
with the PR ref, then remove the label that triggered the run.
2026-06-02 11:38:33 +09:00

107 lines
3.9 KiB
YAML

name: Ecosystem CI
on:
pull_request:
types: [labeled]
permissions: {}
concurrency:
group: ecosystem-ci-${{ github.event.pull_request.number }}-${{ github.event.label.name }}
cancel-in-progress: true
jobs:
trigger:
if: >
(
github.event.label.name == 'run-oxlint-ecosystem-ci' ||
github.event.label.name == 'run-oxfmt-ecosystem-ci'
) &&
github.repository == 'oxc-project/oxc'
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
id: app-token
with:
client-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: oxc-project
repositories: |
${{ github.event.repository.name }}
oxc-ecosystem-ci
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
id: prepare
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const issueNumber = context.payload.pull_request.number;
const branch = context.payload.pull_request.head.ref;
const isOxlint = context.payload.label.name === 'run-oxlint-ecosystem-ci';
const project = isOxlint ? 'Oxlint' : 'Oxfmt';
const workflow = isOxlint ? 'oxlint-ci.yml' : 'oxfmt-ci.yml';
const body = `Triggering ${project} Ecosystem CI for \`${branch}\`\nhttps://github.com/oxc-project/oxc-ecosystem-ci/actions/workflows/${workflow}`;
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
per_page: 100,
});
const existing = comments.findLast((c) =>
c.user.login === 'oxc-guard[bot]' &&
c.body &&
(c.body.startsWith(`Triggering ${project} Ecosystem CI`) || c.body.startsWith(`## [${project} Ecosystem CI]`))
);
let commentId;
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
commentId = existing.id;
} else {
const { data: created } = await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body,
});
commentId = created.id;
}
core.setOutput('ref', `refs/pull/${issueNumber}/head`);
core.setOutput('comment-id', commentId);
core.setOutput('workflow', workflow);
- uses: benc-uk/workflow-dispatch@31e2b3319479a63f0ab15bf800eff9e913504e26 # v1.3.2
with:
repo: oxc-project/oxc-ecosystem-ci
workflow: ${{ steps.prepare.outputs.workflow }}
token: ${{ steps.app-token.outputs.token }}
ref: main
inputs: >-
{
"issue-number": "${{ github.event.pull_request.number }}",
"comment-id": "${{ steps.prepare.outputs.comment-id }}",
"ref": "${{ steps.prepare.outputs.ref }}"
}
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: context.payload.label.name,
});
} catch (error) {
if (error.status !== 404) throw error;
}