Skip to content

Commit 1641c2d

Browse files
committed
Add implementation
1 parent d9136db commit 1641c2d

File tree

417 files changed

+96926
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

417 files changed

+96926
-0
lines changed

.github/workflows/e2e_test.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: e2e-test
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
e2e-test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
# Replace @main with the commit hash of the latest commit on the pull request branch
12+
- uses: nilsreichardt/verify-safe-to-test-label@main

action.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'Remove "safe to test" label'
2+
description: 'Removes the "safe to test" label if the PR is a fork and the label is present'
3+
inputs:
4+
label:
5+
description: 'The name of the lable that should be removed when it is present'
6+
required: false
7+
default: 'safe to test'
8+
runs:
9+
using: 'node16'
10+
main: 'index.js'

index.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const core = require('@actions/core');
2+
const github = require('@actions/github');
3+
4+
async function run() {
5+
try {
6+
const context = github.context;
7+
8+
const allowedEvents = ['pull_request', 'pull_request_target', 'merge_group'];
9+
if (allowedEvents.indexOf(context.eventName) === -1) {
10+
core.setFailed(`This action only works with the following events: ${allowedEvents.join(', ')}.`);
11+
return;
12+
}
13+
14+
const headRepoFullName = context.payload.pull_request.head.repo.full_name;
15+
const baseRepoFullName = context.payload.repository.full_name;
16+
17+
const isFork = headRepoFullName !== baseRepoFullName;
18+
if (!isFork) {
19+
console.log(`Pull request is not from a fork, skipping.`);
20+
return;
21+
}
22+
23+
const safeToTestLabelName = core.getInput('label');
24+
25+
// Check if pull request has the "safe-to-test" label
26+
const labels = context.payload.pull_request.labels;
27+
const hasSafeToTestLabel = labels.find(label => label.name === safeToTestLabelName);
28+
if (hasSafeToTestLabel) {
29+
console.log(`Pull request have the "safe-to-test" label, skipping.`);
30+
return;
31+
}
32+
33+
core.setFailed(`Pull request does not have the "safe-to-test" label. Code owners must add the "safe-to-test" label to the pull request before it can be tested.`);
34+
} catch (error) {
35+
core.setFailed(error.message);
36+
}
37+
}
38+
39+
run();

node_modules/.bin/uuid

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.package-lock.json

+227
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/LICENSE.md

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)