Skip to content

Commit

Permalink
chore: support passing refs to ecosystem-ci (#4657)
Browse files Browse the repository at this point in the history
* chore: support passing refs to ecosystem-ci

* chore: fix matching
  • Loading branch information
h-a-n-a authored Nov 15, 2023
1 parent f32f5be commit 2666fca
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions .github/workflows/ecosystem-ci-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
trigger:
runs-on: ubuntu-latest
if: github.repository == 'web-infra-dev/rspack' && github.event.issue.pull_request && startsWith(github.event.comment.body, '!eco-ci')
if: github.repository == 'web-infra-dev/rspack' && github.event.issue.pull_request && contains(github.event.comment.body, '!eco-ci')
steps:
- uses: actions/github-script@v6
with:
Expand Down Expand Up @@ -69,9 +69,16 @@ jobs:
result-encoding: string
script: |
const comment = process.env.COMMENT.trim()
const command = comment.split('\n')[0]
const prData = ${{ steps.get-pr-data.outputs.result }}
const suite = comment.split('\n')[0].replace(/^!eco-ci/, '').trim()
const {
MODERN_REF: modernRef,
RSPRESS_REF: rspressRef,
RSBUILD_REF: rsbuildRef
} = parseEnv(command.split(/\s/))
const suite = command.replace(/^.*?!eco-ci/, '').trim()
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
Expand All @@ -82,6 +89,31 @@ jobs:
prNumber: '' + prData.num,
branchName: prData.branchName,
repo: prData.repo,
suite: suite === '' ? '-' : suite
suite: suite === '' ? '-' : suite,
modernRef,
rspressRef,
rsbuildRef
}
})
function parseEnv(args) {
const envSetterRegex = /(\w+)=('(.*)'|"(.*)"|(.*))/
const envSetters = {}
for (let i = 0; i < args.length; i++) {
const match = envSetterRegex.exec(args[i])
if (match) {
let value
if (typeof match[3] !== 'undefined') {
value = match[3]
} else if (typeof match[4] === 'undefined') {
value = match[5]
} else {
value = match[4]
}
envSetters[match[1]] = value
}
}
return envSetters
}

0 comments on commit 2666fca

Please sign in to comment.