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