mirror of
https://github.com/ubicloud/ubicloud.git
synced 2025-10-04 13:52:06 +08:00
Bumps the github-actions-dependencies group with 3 updates: [actions/setup-node](https://github.com/actions/setup-node), [actions/setup-go](https://github.com/actions/setup-go) and [actions/github-script](https://github.com/actions/github-script). Updates `actions/setup-node` from 4 to 5 - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v4...v5) Updates `actions/setup-go` from 5 to 6 - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v5...v6) Updates `actions/github-script` from 7 to 8 - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v7...v8) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions-dependencies - dependency-name: actions/setup-go dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions-dependencies - dependency-name: actions/github-script dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
65 lines
2.3 KiB
YAML
65 lines
2.3 KiB
YAML
name: Trigger E2E tests
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
pull-requests: write
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
jobs:
|
|
pr_comment:
|
|
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/run-e2e')
|
|
runs-on: ubicloud
|
|
steps:
|
|
- name: Trigger E2E tests
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
// Check if the comment is from a contributor
|
|
const contributors = await github.rest.repos.listContributors({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo
|
|
});
|
|
const contributorIds = contributors.data.map(c => c.id);
|
|
const isContributor = contributorIds.includes(context.payload.comment.user.id);
|
|
|
|
// Check if the given test cases string is secure or empty
|
|
const testCases = (context.payload.comment.body.trim().split(/\s+/)[1]) || '';
|
|
console.log(`testCases: ${testCases}`);
|
|
const isValid = testCases ? /^[a-zA-Z0-9_,-]+$/.test(testCases) : true;
|
|
console.log(`Is valid: ${isValid}`);
|
|
|
|
const allowedToRun = isContributor && isValid;
|
|
|
|
// Add a reaction to the comment
|
|
await github.rest.reactions.createForIssueComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: context.payload.comment.id,
|
|
content: allowedToRun ? 'rocket' : '-1'
|
|
})
|
|
|
|
if (!allowedToRun) {
|
|
console.log('Not allowed to run E2E tests');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Get pull request details
|
|
const pullRequest = await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.payload.issue.number
|
|
});
|
|
|
|
// Create a workflow dispatch event
|
|
const inputs = testCases ? { test_cases: testCases } : {}
|
|
await github.rest.actions.createWorkflowDispatch({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
workflow_id: 'e2e.yml',
|
|
ref: pullRequest.data.head.ref,
|
|
inputs: inputs
|
|
});
|