Skip to content

Commit 2f3589e

Browse files
committed
Minor fixes
1 parent ce98522 commit 2f3589e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

actions/automation-config/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,7 @@ runs:
3737
else:
3838
config = {}
3939
40+
print(json.dumps(config, indent=2))
41+
4042
with open(os.getenv("GITHUB_OUTPUT"), "a") as fp:
4143
fp.write(f"config={json.dumps(config)}\n")

actions/dispatch-event/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ runs:
2121
| while read repo; do
2222
echo "sending ${{ inputs.event }} event to ${repo} ..."
2323
curl -Ls --fail-with-body -X POST \
24-
-H 'Authorization: Bearer ${{ secrets.github-token }}' \
24+
-H 'Authorization: Bearer ${{ inputs.github-token }}' \
2525
-H 'Accept: application/vnd.github.v3+json' \
2626
-H 'Content-Type: application/json' \
2727
'https://api.github.com/repos/${repo}/dispatches' \

packages/functions/redispatch/entrypoint.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ func Main(args map[string]any) map[string]any {
7171
if err != nil {
7272
return makeErr(http.StatusForbidden, "can't decrypt GH_TOKEN")
7373
}
74+
if !strings.HasPrefix(ghToken, "ghp_") && !strings.HasPrefix(ghToken, "github_pat_") {
75+
return makeErr(http.StatusForbidden, "can't validate GH_TOKEN")
76+
}
7477

7578
// get body
7679
body, ok := httpArg["body"].(string)
@@ -209,12 +212,13 @@ func Main(args map[string]any) map[string]any {
209212
dispReqPayload["ref"] = refName
210213
}
211214

212-
dispReqBody, _ := json.Marshal(map[string]any{
215+
dispReqBody := map[string]any{
213216
"event_type": dispEvent,
214217
"client_payload": dispReqPayload,
215-
})
218+
}
219+
dispReqBodyBytes, _ := json.Marshal(dispReqBody)
216220

217-
dispReq, _ := http.NewRequest("POST", dispReqURL, bytes.NewReader(dispReqBody))
221+
dispReq, _ := http.NewRequest("POST", dispReqURL, bytes.NewReader(dispReqBodyBytes))
218222
dispReq.Header.Set("Authorization", "Bearer "+ghToken)
219223
dispReq.Header.Set("Accept", "application/vnd.github.v3+json")
220224
dispReq.Header.Set("Content-Type", "application/json")

0 commit comments

Comments
 (0)