| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- name: ecosystem-ci trigger
- on:
- issue_comment:
- types: [created]
- permissions:
- contents: read
- issues: write
- pull-requests: read
- jobs:
- trigger:
- runs-on: ubuntu-latest
- if: github.repository == 'vuejs/core' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/ecosystem-ci run')
- steps:
- - name: Check user permission
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
- with:
- script: |
- const user = context.payload.sender.login
- console.log(`Validate user: ${user}`)
- let isVuejsMember = false
- try {
- const { status } = await github.rest.orgs.checkMembershipForUser({
- org: 'vuejs',
- username: user
- });
- isVuejsMember = (status === 204)
- } catch (e) {}
- if (isVuejsMember) {
- console.log('Allowed')
- await github.rest.reactions.createForIssueComment({
- owner: context.repo.owner,
- repo: context.repo.repo,
- comment_id: context.payload.comment.id,
- content: '+1',
- })
- } else {
- console.log('Not allowed')
- await github.rest.reactions.createForIssueComment({
- owner: context.repo.owner,
- repo: context.repo.repo,
- comment_id: context.payload.comment.id,
- content: '-1',
- })
- throw new Error('not allowed')
- }
- - name: Get PR info
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
- id: get-pr-data
- with:
- script: |
- console.log(`Get PR info: ${context.repo.owner}/${context.repo.repo}#${context.issue.number}`)
- const { data: pr } = await github.rest.pulls.get({
- owner: context.repo.owner,
- repo: context.repo.repo,
- pull_number: context.issue.number
- })
- return {
- num: context.issue.number,
- branchName: pr.head.ref,
- repo: pr.head.repo.full_name,
- commit: pr.head.sha
- }
- - name: Trigger run
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
- id: trigger
- env:
- COMMENT: ${{ github.event.comment.body }}
- with:
- github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
- result-encoding: string
- script: |
- const comment = process.env.COMMENT.trim()
- const prData = ${{ steps.get-pr-data.outputs.result }}
- const suite = comment.replace(/^\/ecosystem-ci run/, '').trim()
- await github.rest.actions.createWorkflowDispatch({
- owner: context.repo.owner,
- repo: 'ecosystem-ci',
- workflow_id: 'ecosystem-ci-from-pr.yml',
- ref: 'main',
- inputs: {
- prNumber: '' + prData.num,
- branchName: prData.branchName,
- repo: prData.repo,
- suite: suite === '' ? '-' : suite,
- commit: prData.commit
- }
- })
|