mirror of
https://github.com/webiny/action-conventional-commits.git
synced 2024-11-23 10:21:51 +01:00
feat: add token in api request header for private repos
This commit is contained in:
parent
679da979e4
commit
c12108d422
5 changed files with 21126 additions and 16497 deletions
|
@ -24,4 +24,7 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: webiny/action-conventional-commits@v1.1.0
|
||||
# optional, required for private repos
|
||||
# with:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
name: "Conventional Commits"
|
||||
description: "Ensures that all commit messages are following the conventional-commits standard."
|
||||
inputs:
|
||||
GITHUB_TOKEN:
|
||||
description: 'GitHub token'
|
||||
required: false
|
||||
runs:
|
||||
using: node16
|
||||
main: dist/main/index.js
|
||||
|
|
37341
dist/main/index.js
vendored
37341
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@ type Commit = {
|
|||
message: string;
|
||||
};
|
||||
|
||||
const extractCommits = async (context): Promise<Commit[]> => {
|
||||
const extractCommits = async (context, core): Promise<Commit[]> => {
|
||||
// For "push" events, commits can be found in the "context.payload.commits".
|
||||
const pushCommits = Array.isArray(get(context, "payload.commits"));
|
||||
if (pushCommits) {
|
||||
|
@ -16,8 +16,15 @@ const extractCommits = async (context): Promise<Commit[]> => {
|
|||
const prCommitsUrl = get(context, "payload.pull_request.commits_url");
|
||||
if (prCommitsUrl) {
|
||||
try {
|
||||
let requestHeaders = {
|
||||
"Accept": "application/vnd.github+json",
|
||||
}
|
||||
if (core.getInput('GITHUB_TOKEN') != "") {
|
||||
requestHeaders["Authorization"] = "token " + core.getInput('GITHUB_TOKEN')
|
||||
}
|
||||
const { body } = await got.get(prCommitsUrl, {
|
||||
responseType: "json",
|
||||
headers: requestHeaders,
|
||||
});
|
||||
|
||||
if (Array.isArray(body)) {
|
||||
|
|
|
@ -9,7 +9,7 @@ async function run() {
|
|||
`ℹ️ Checking if commit messages are following the Conventional Commits specification...`
|
||||
);
|
||||
|
||||
const extractedCommits = await extractCommits(context);
|
||||
const extractedCommits = await extractCommits(context, core);
|
||||
if (extractedCommits.length === 0) {
|
||||
core.info(`No commits to check, skipping...`);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue