Skip to content

Commit 347eee5

Browse files
committed
add printing of the context.
1 parent 2bc7184 commit 347eee5

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Rebuild Stale PullRequests'
22
description: 'Automatically rebuild pull requests when they become stale or the target branch changes.'
33
inputs:
44
github_token:
5-
description: 'GITHUB_TOKEN, must be specified to be the value: {{ secrets.GITHUB_TOKEN }}'
5+
description: 'GITHUB_TOKEN, must be specified to be the value: ${{ secrets.GITHUB_TOKEN }}'
66
branding:
77
icon: 'arrow-right-circle'
88
color: 'green'

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"dependencies": {
3030
"@actions/core": "^1.6.0",
3131
"@actions/github": "^5.1.1",
32-
"axios": "^0.27.2"
32+
"axios": "^0.27.2",
33+
"json-stringify-safe": "^5.0.1"
3334
},
3435
"engines": {
3536
"node": "^16.0"

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
const core = require('@actions/core');
22
const github = require('@actions/github');
3+
const stringify = require('json-stringify-safe');
34

45
async function run() {
56
// Attempt to load credentials from the GitHub OIDC provider.
67
const githubSecretAccessToken = core.getInput('github_token');
78
if (!githubSecretAccessToken || githubSecretAccessToken === '{{ secrets.GITHUB_TOKEN }}') {
8-
core.setFailed("Missing use with configuration in the github action, please add to the github workflow: 'github_token: {{ secrets.GITHUB_TOKEN }}'");
9+
core.setFailed("Missing use with configuration in the github action, please add to the github workflow: 'github_token: ${{ secrets.GITHUB_TOKEN }}'");
910
core.getInput('github_token', { required: true });
1011
throw Error('InvalidInput');
1112
}
1213

1314
// https://docs.github.com/en/actions/learn-github-actions/contexts#example-contents-of-the-github-contex
1415
const { repository, repository_owner: owner, ref_name: currentRef, ref_type: triggerType } = github.context;
16+
if (!triggerType) {
17+
core.info(stringify(github));
18+
core.setFailed('No trigger type set');
19+
throw Error('InvalidInput');
20+
}
1521
if (triggerType !== 'branch') {
1622
core.info(`Skipping check because trigger type is not branch. Trigger Type: ${triggerType}, Ref: ${currentRef}`);
1723
return;

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,6 +2357,11 @@ json-stable-stringify-without-jsonify@^1.0.1:
23572357
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
23582358
integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
23592359

2360+
json-stringify-safe@^5.0.1:
2361+
version "5.0.1"
2362+
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
2363+
integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==
2364+
23602365
json5@^1.0.1:
23612366
version "1.0.1"
23622367
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"

0 commit comments

Comments
 (0)