-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
38 lines (31 loc) · 1.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const core = require('@actions/core');
const github = require('@actions/github');
const issuecheck = require('./issuecheck.js')
async function run() {
try {
const authToken = core.getInput('github_token', {required: true});
const owner = github.context.payload.pull_request.base.user.login;
const repo = github.context.payload.pull_request.base.repo.name;
const pr_number = github.context.payload.pull_request.number;
const client = new github.GitHub(authToken);
const {data: pullRequest} = await client.pulls.get({
owner,
repo,
pull_number: pr_number
});
const title = pullRequest.title;
const description = pullRequest.body;
const branch = pullRequest.head.ref;
const issue = issuecheck.findIssue(core.getInput("prefix"), title, description, branch);
core.info(`Issue ${issue} found`)
} catch {
core.setFailed("Issue not found in PR: All PRs must have an associated issue");
core.info(`
Linear supports three ways to link issues with your pull requests:
1. Include *issue ID* in the branch name
2. Include *issue ID* in the PR title
3. Include *issue ID* with a magic word in the PR description (e.g. Fixes ENG-123) similar to GitHub Issues
`)
}
}
run();