diff --git a/.github/workflows/CI_ReSim_trigger.yml b/.github/workflows/CI_ReSim_trigger.yml new file mode 100644 index 0000000000..cbc3863230 --- /dev/null +++ b/.github/workflows/CI_ReSim_trigger.yml @@ -0,0 +1,52 @@ +name: CI_ReSim_trigger + +on: + pull_request_target: + types: [opened, labeled, synchronize, reopened] + branches: + - master + - maint/** +permissions: + contents: read + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + github-token: ${{ secrets.LTX_SIMULATION_TOKEN }} + script: | + const prNumber = context.payload.pull_request?.number ?? context.payload.number; + + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + }); + + const labels = (pr.labels || []).map(l => typeof l === 'string' ? l : l.name); + const hasLabel = labels.includes('ready_for_ci'); + const author = context.payload.pull_request.user.login; + + const isLabeledEvent = context.payload.action === 'labeled'; + const addedLabel = context.payload.label?.name; + + if (isLabeledEvent && addedLabel !== 'ready_for_ci') { + core.info(`Ignoring label event for: ${addedLabel}`); + return; + } + + await github.rest.repos.createDispatchEvent({ + owner: '${{ secrets.PRIVATE_CI_OWNER }}', + repo: '${{ secrets.PRIVATE_CI_REPO }}', + event_type: 'CI_trigger_type', + client_payload: { + number: prNumber, + head_sha: pr.head.sha, + base_sha: pr.base.sha, + has_label: hasLabel, + author: author, + github_repo: context.repo.full_name + } + });