-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
18 lines (17 loc) · 737 Bytes
/
index.js
File metadata and controls
18 lines (17 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const core = require('@actions/core');
const github = require('@actions/github');
const { exec } = require('child_process');
try {
const token = core.getInput('github-oauth-token');
const { GITHUB_REPOSITORY, GITHUB_SHA } = process.env;
const command = `curl -s -H "Accept: application/vnd.github.groot-preview+json" -H "Authorization: token ${token}" https://api.github.com/repos/${ GITHUB_REPOSITORY }/commits/${ GITHUB_SHA }/pulls | jq -r '.[].number'`;
exec(command, (err, prNumber, stderr) => {
if (err) {
throw err;
}
const url = prNumber && `https://github.com/${ GITHUB_REPOSITORY }/pull/${ prNumber.trim() }`;
core.setOutput("url", url);
});
} catch (error) {
core.setFailed(error.message);
}