-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-github-issue-test.sh
More file actions
executable file
·42 lines (33 loc) · 1.7 KB
/
create-github-issue-test.sh
File metadata and controls
executable file
·42 lines (33 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Test your GitHub Personal Access Token by creating an issue.
# If this works, the PactFlow webhook dispatch will also work.
#
# Usage: ./scripts/one-time-scripts/create-github-issue-test.sh
set -eu
# ── Fill in these values ─────────────────────────────────────────────
GITHUB_REPO_OWNER="seontechnologies"
GITHUB_REPO_NAME="pactjs-utils"
GITHUB_AUTH_TOKEN="Your_GitHub_Personal_Access_Token"
# ─────────────────────────────────────────────────────────────────────
ISSUE_TITLE="Test issue - webhook PAT verification"
ISSUE_BODY="This is a test issue created via API. You can close and delete this."
# Step 1: Verify the GitHub Token
echo "Verifying GitHub token..."
TOKEN_VERIFICATION_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer $GITHUB_AUTH_TOKEN" \
"https://api.github.com/users/$GITHUB_REPO_OWNER")
if [ "$TOKEN_VERIFICATION_RESPONSE" -ne 200 ]; then
echo "Error: Bad credentials. Please check your GitHub token and ensure it has the required permissions."
exit 1
else
echo "GitHub token verified successfully."
fi
# Step 2: Create the issue
ISSUE_URL="https://api.github.com/repos/$GITHUB_REPO_OWNER/$GITHUB_REPO_NAME/issues"
echo "Creating a new GitHub issue..."
curl -X POST "$ISSUE_URL" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_AUTH_TOKEN" \
-d "{\"title\": \"$ISSUE_TITLE\", \"body\": \"$ISSUE_BODY\"}"
echo ""
echo "If an issue was created, your token works for webhook dispatch."