Skip to content
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
61fb7b6
feat: support spec inputs in GitHub Action (github_org, patcher_githu…
wakeful Aug 15, 2025
f32fe87
feat: add support for GitHub Enterprise and GitLab
devin-ai-integration[bot] Aug 29, 2025
6db98c3
refactor: auto-detect SCM API versions
devin-ai-integration[bot] Aug 29, 2025
093c7ce
refactor: rename inputs to be SCM-agnostic
devin-ai-integration[bot] Aug 29, 2025
4b15b2f
chore: bump version to 3.0.0 for breaking changes
devin-ai-integration[bot] Aug 29, 2025
a184068
fix: handle authentication errors gracefully in CI
devin-ai-integration[bot] Aug 29, 2025
adc41f3
test: trigger CI to verify updated token permissions
devin-ai-integration[bot] Aug 29, 2025
dae851a
fix: correct octokit baseUrl for github.com and update patcher to v0.…
devin-ai-integration[bot] Aug 29, 2025
099422f
fix: update dist files with correct formatting
devin-ai-integration[bot] Aug 29, 2025
c215a01
fix: correct token format for binary downloads from 'token' to 'Bearer'
devin-ai-integration[bot] Aug 29, 2025
1c95b2a
fix: use asset.url instead of browser_download_url for private repo d…
devin-ai-integration[bot] Aug 29, 2025
ba22766
fix: address PR feedback - improve types, naming, and terrapatch SCM …
devin-ai-integration[bot] Aug 29, 2025
a2634e7
docs: add terrapatch_scm_org to README input parameters table
devin-ai-integration[bot] Aug 29, 2025
dad5475
fix: allow GitHub Enterprise validation for custom organizations
devin-ai-integration[bot] Aug 30, 2025
b3893fd
improve: enhance error messaging for GitHub Enterprise token permissi…
devin-ai-integration[bot] Aug 30, 2025
dc3b244
fix: implement dual SCM provider for GitHub Enterprise and third-part…
devin-ai-integration[bot] Sep 2, 2025
ad18bc0
feat: add GitHub access token validation workflow
devin-ai-integration[bot] Sep 2, 2025
2ae5aeb
refactor: add TFUPDATE_ORG constant and reorder tool constants for co…
devin-ai-integration[bot] Sep 2, 2025
07783bc
refactor: remove GitLab support and simplify SCM provider to GitHub-only
devin-ai-integration[bot] Sep 2, 2025
3b69d0f
Remove example patcher-action usage from workflow
josh-padnick Sep 2, 2025
ba6b844
refactor: rename SCM variables to GitHub-specific names for clarity
devin-ai-integration[bot] Sep 2, 2025
68e1cf2
Merge branch 'feat-custom-org' of https://git-manager.devin.ai/proxy/…
devin-ai-integration[bot] Sep 2, 2025
df822f2
refactor: rename final SCM variable reference to GitHub-specific name
devin-ai-integration[bot] Sep 2, 2025
12d3d4a
docs: update README.md to use GitHub-specific input names
devin-ai-integration[bot] Sep 2, 2025
4ad7435
refactor: complete SCM-to-GitHub variable renaming in all files
devin-ai-integration[bot] Sep 2, 2025
129ac60
feat: rename auth_token to github_token with backward compatibility
devin-ai-integration[bot] Sep 2, 2025
7353023
build: update compiled dist/index.js with github_token changes
devin-ai-integration[bot] Sep 2, 2025
5b4ac27
Restore some missing action vars.
josh-padnick Sep 2, 2025
d8ed421
feat: add read_token and update_token support with fallback mechanism
devin-ai-integration[bot] Sep 2, 2025
8dc356e
resolve: merge conflict in action.yml - combine auth_token deprecatio…
devin-ai-integration[bot] Sep 2, 2025
a8b79e7
Fix parameter mismatch.
josh-padnick Sep 2, 2025
e516c0e
fix: correct input parameter names for pull_request_branch and pull_r…
devin-ai-integration[bot] Sep 2, 2025
b8d10f3
Merge branch 'feat-custom-org' of https://git-manager.devin.ai/proxy/…
devin-ai-integration[bot] Sep 2, 2025
6b0ffe8
Update index.js
josh-padnick Sep 2, 2025
0cb678e
fix: use appropriate tokens for GitHub Enterprise vs GitHub.com tool …
devin-ai-integration[bot] Sep 2, 2025
21e44b5
resolve: merge conflict in dist/index.js by rebuilding from source
devin-ai-integration[bot] Sep 2, 2025
254b89d
Update docs vars.
josh-padnick Sep 2, 2025
21eaa71
fix: route public tool downloads via GitHub.com; add github_base_url/…
devin-ai-integration[bot] Sep 2, 2025
6cc9d71
feat: explicit Public vs Gruntwork tooling routing; force GitHub.com …
devin-ai-integration[bot] Sep 3, 2025
f3087f4
refactor: constants read from inputs; tool groups reference repo vars…
devin-ai-integration[bot] Sep 3, 2025
b73bae6
fix: use Authorization: token for releases; retry unauthenticated on …
devin-ai-integration[bot] Sep 3, 2025
cd690a3
Trivial spaces added
josh-padnick Sep 3, 2025
de8d4bc
Clean up download function; use thoughtful handling between browser d…
josh-padnick Sep 3, 2025
a325100
Yet another tweak.
josh-padnick Sep 3, 2025
858c090
Remove browser downloads entirely, a giant red herring.
josh-padnick Sep 3, 2025
c5369d4
Remove auth_token
josh-padnick Sep 3, 2025
718db58
Remove auth_token
josh-padnick Sep 3, 2025
e2fac86
Sadly support HTTP because some GitHub Enterprise instances might use…
josh-padnick Sep 3, 2025
b47095a
Fix two issues:
josh-padnick Sep 3, 2025
c67cc27
Remove errant file.
josh-padnick Sep 4, 2025
796c5b1
Use env vars to interpolate vals.
josh-padnick Sep 4, 2025
0ad7908
Update action.yml
josh-padnick Sep 4, 2025
9038475
Implement PR feedback
josh-padnick Sep 4, 2025
5547963
chore: fix GitHub Actions parameters
wakeful Sep 4, 2025
de38fa9
chore: Bumping to Patcher `v0.16.0`
yhakbar Sep 15, 2025
e634a47
fix: Cleaning up README.md
yhakbar Sep 15, 2025
615307a
chore: Running `yarn build`
yhakbar Sep 15, 2025
5f7dff6
Revert "chore: Running `yarn build`"
yhakbar Sep 15, 2025
62341cd
chore: Running `yarn build` with Yarn `v1.22.22`
yhakbar Sep 15, 2025
f69d40d
Revert "chore: Running `yarn build` with Yarn `v1.22.22`"
yhakbar Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
with:
github_token: ${{ secrets.PATCHER_FULL_REPO }}
patcher_command: report
patcher_version: v0.15.1
patcher_version: v0.15.2
working_dir: infrastructure-live
spec_file: spec.json
include_dirs: "{*dev*}/**"
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
with:
github_token: ${{ secrets.PATCHER_FULL_REPO }}
patcher_command: update
patcher_version: v0.15.1
patcher_version: v0.15.2
working_dir: infrastructure-live
spec_file: spec.json
pull_request_title: "[Patcher] [dev] Update ${{ matrix.ID }}"
Expand Down
322 changes: 322 additions & 0 deletions .github/workflows/validate-github-access.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
name: Validate GitHub Access Token

on:
workflow_dispatch:
inputs:
github_base_url:
description: 'GitHub Base URL (use https://github.com for GitHub.com or your GitHub Enterprise URL)'
required: true
default: 'https://github.com'
type: string
github_org:
description: 'Organization name where your repositories are located'
required: true
default: 'gruntwork-io'
type: string
test_repo:
description: 'Repository name to test access (should be accessible with your token)'
required: true
default: 'patcher-cli'
type: string
test_version:
description: 'Release version to test (optional, defaults to latest)'
required: false
default: 'v0.15.2'
type: string
github_token_secret:
description: 'Name of the secret containing your GitHub token (defaults to GITHUB_TOKEN)'
required: false
default: 'GITHUB_TOKEN'
type: string

jobs:
validate-access:
name: Validate GitHub Access
runs-on: ubuntu-latest

steps:
- name: Validate Inputs
env:
GITHUB_BASE_URL: ${{ inputs.github_base_url }}
GITHUB_ORG: ${{ inputs.github_org }}
TEST_REPO: ${{ inputs.test_repo }}
TEST_VERSION: ${{ inputs.test_version }}
GITHUB_TOKEN_SECRET: ${{ inputs.github_token_secret }}
run: |
echo "🔍 Validating GitHub Access Token"
echo "=================================="
echo "GitHub Base URL: ${GITHUB_BASE_URL}"
echo "Organization: ${GITHUB_ORG}"
echo "Test Repository: ${TEST_REPO}"
echo "Test Version: ${TEST_VERSION}"
echo "Token Secret: ${GITHUB_TOKEN_SECRET}"
echo ""

# Validate URL format
if [[ "${GITHUB_BASE_URL}" != http* ]]; then
echo "❌ ERROR: GitHub Base URL must start with http:// or https://"
exit 1
fi

- name: Test Repository Access
env:
GH_TOKEN: ${{ secrets[inputs.github_token_secret] }}
GITHUB_BASE_URL: ${{ inputs.github_base_url }}
GITHUB_ORG: ${{ inputs.github_org }}
REPO_NAME: ${{ inputs.test_repo }}
TEST_VERSION: ${{ inputs.test_version }}
run: |
echo "🔍 Testing Repository Access"
echo "============================"

# Check if token is provided
if [[ -z "$GH_TOKEN" ]]; then
echo "❌ ERROR: GitHub token not found in secrets.${GITHUB_TOKEN_SECRET}"
echo ""
echo "💡 SOLUTION: Add your GitHub token to repository secrets with name '${GITHUB_TOKEN_SECRET}'"
echo " For GitHub.com: Create a Personal Access Token with 'repo' scope"
echo " For GitHub Enterprise: Create a token with 'repo' scope on your enterprise instance"
exit 1
fi

# Determine API URL (same logic as patcher-action)
if [ "$GITHUB_BASE_URL" = "https://github.com" ]; then
API_URL="https://api.github.com"
echo "🌐 Using GitHub.com API: $API_URL"
else
API_URL="${GITHUB_BASE_URL}/api/v3"
echo "🏢 Using GitHub Enterprise API: $API_URL"
fi

echo ""
echo "📋 Testing access to: ${GITHUB_BASE_URL}/${GITHUB_ORG}/${REPO_NAME}"

# Test repository access
response=$(curl -s -w "%{http_code}" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
-H "User-Agent: patcher-action-validator" \
"${API_URL}/repos/${GITHUB_ORG}/${REPO_NAME}" \
-o /tmp/repo_response.json)

http_code="${response: -3}"
echo "📡 Repository API Response: $http_code"

if [ "$http_code" = "200" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: This could be a case statement.

echo "✅ SUCCESS: Repository access granted!"
echo ""
echo "📊 Repository Details:"
if command -v jq >/dev/null 2>&1; then
cat /tmp/repo_response.json | jq -r '" Name: " + .name, " Full Name: " + .full_name, " Private: " + (.private | tostring), " Default Branch: " + .default_branch'
else
echo " (jq not available for detailed parsing)"
fi
elif [ "$http_code" = "404" ]; then
echo "❌ ERROR: Repository not found (404)"
echo ""
echo "💡 POSSIBLE CAUSES:"
echo " 1. Repository '${GITHUB_ORG}/${REPO_NAME}' does not exist"
echo " 2. Repository is private and your token doesn't have access"
echo " 3. Organization name '${GITHUB_ORG}' is incorrect"
echo " 4. Repository name '${REPO_NAME}' is incorrect"
echo ""
echo "🔧 SOLUTIONS:"
echo " 1. Verify the repository exists at: ${GITHUB_BASE_URL}/${GITHUB_ORG}/${REPO_NAME}"
echo " 2. Ensure your token has 'repo' scope for private repositories"
echo " 3. Check that you have access to the organization/repository"
echo ""
echo "📄 API Response:"
cat /tmp/repo_response.json
exit 1
elif [ "$http_code" = "401" ]; then
echo "❌ ERROR: Authentication failed (401)"
echo ""
echo "💡 POSSIBLE CAUSES:"
echo " 1. Invalid or expired GitHub token"
echo " 2. Token format is incorrect"
echo ""
echo "🔧 SOLUTIONS:"
echo " 1. Generate a new Personal Access Token"
echo " 2. Ensure token has 'repo' scope"
echo " 3. For GitHub Enterprise: Verify token was created on the correct instance"
echo ""
echo "📄 API Response:"
cat /tmp/repo_response.json
exit 1
elif [ "$http_code" = "403" ]; then
echo "❌ ERROR: Access forbidden (403)"
echo ""
echo "💡 POSSIBLE CAUSES:"
echo " 1. Token lacks required permissions (needs 'repo' scope)"
echo " 2. Organization has restricted access policies"
echo " 3. Repository access is restricted"
echo ""
echo "🔧 SOLUTIONS:"
echo " 1. Regenerate token with 'repo' scope"
echo " 2. Contact organization admin for repository access"
echo " 3. Verify you're a member of the organization"
echo ""
echo "📄 API Response:"
cat /tmp/repo_response.json
exit 1
else
echo "❌ ERROR: Unexpected response code ($http_code)"
echo ""
echo "💡 This might indicate:"
echo " 1. Network connectivity issues"
echo " 2. GitHub Enterprise server problems"
echo " 3. API endpoint changes"
echo ""
echo "📄 API Response:"
cat /tmp/repo_response.json
exit 1
fi

- name: Test Release Access
env:
GH_TOKEN: ${{ secrets[inputs.github_token_secret] }}
GITHUB_BASE_URL: ${{ inputs.github_base_url }}
GITHUB_ORG: ${{ inputs.github_org }}
REPO_NAME: ${{ inputs.test_repo }}
TEST_VERSION: ${{ inputs.test_version }}
run: |
echo ""
echo "🔍 Testing Release Access"
echo "========================"

# Determine API URL
if [ "$GITHUB_BASE_URL" = "https://github.com" ]; then
API_URL="https://api.github.com"
else
API_URL="${GITHUB_BASE_URL}/api/v3"
fi

echo "📋 Testing release access for version: ${TEST_VERSION}"

# Test release access
release_response=$(curl -s -w "%{http_code}" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
-H "User-Agent: patcher-action-validator" \
"${API_URL}/repos/${GITHUB_ORG}/${REPO_NAME}/releases/tags/${TEST_VERSION}" \
-o /tmp/release_response.json)

release_http_code="${release_response: -3}"
echo "📡 Release API Response: $release_http_code"

if [ "$release_http_code" = "200" ]; then
echo "✅ SUCCESS: Release access granted!"
echo ""
echo "📊 Release Details:"
if command -v jq >/dev/null 2>&1; then
cat /tmp/release_response.json | jq -r '" Tag: " + .tag_name, " Name: " + .name, " Published: " + .published_at, " Assets: " + (.assets | length | tostring)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Unnecessary cat. See comment above.

else
echo " (jq not available for detailed parsing)"
fi
elif [ "$release_http_code" = "404" ]; then
echo "⚠️ WARNING: Release not found (404)"
echo ""
echo "💡 This might mean:"
echo " 1. Version '${TEST_VERSION}' doesn't exist"
echo " 2. Release exists but is private/draft"
echo ""
echo "🔧 SOLUTIONS:"
echo " 1. Check available releases at: ${GITHUB_BASE_URL}/${GITHUB_ORG}/${REPO_NAME}/releases"
echo " 2. Try with a different version number"
echo " 3. This may not affect patcher-action if using latest releases"
echo ""
echo "📄 API Response:"
cat /tmp/release_response.json
else
echo "❌ ERROR: Release access failed ($release_http_code)"
echo ""
echo "💡 This could indicate permission issues with release assets"
echo ""
echo "📄 API Response:"
cat /tmp/release_response.json
exit 1
fi

- name: Test Token Permissions
env:
GH_TOKEN: ${{ secrets[inputs.github_token_secret] }}
GITHUB_BASE_URL: ${{ inputs.github_base_url }}
run: |
echo ""
echo "🔍 Testing Token Permissions"
echo "==========================="

# Determine API URL
if [ "$GITHUB_BASE_URL" = "https://github.com" ]; then
API_URL="https://api.github.com"
else
API_URL="${GITHUB_BASE_URL}/api/v3"
fi

echo "📋 Testing token user information access"

# Test user/token info
user_response=$(curl -s -w "%{http_code}" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
-H "User-Agent: patcher-action-validator" \
"${API_URL}/user" \
-o /tmp/user_response.json)

user_http_code="${user_response: -3}"
echo "📡 User API Response: $user_http_code"

if [ "$user_http_code" = "200" ]; then
echo "✅ SUCCESS: Token permissions validated!"
echo ""
echo "👤 Token Details:"
if command -v jq >/dev/null 2>&1; then
cat /tmp/user_response.json | jq -r '" User: " + .login, " Type: " + .type, " Name: " + (.name // "Not set")'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Unnecessary cat. See comment above.

else
echo " (jq not available for detailed parsing)"
fi
elif [ "$user_http_code" = "403" ]; then
echo "⚠️ WARNING: Limited token permissions (403)"
echo ""
echo "💡 This means:"
echo " 1. Token works but has restricted user info access"
echo " 2. Common with GitHub App tokens or restricted PATs"
echo " 3. May still work for repository operations"
echo ""
echo "🔧 If patcher-action fails:"
echo " 1. Try using a Personal Access Token instead"
echo " 2. Ensure token has 'user' scope if user info is needed"
echo ""
echo "📄 API Response:"
cat /tmp/user_response.json
else
echo "❌ ERROR: Token validation failed ($user_http_code)"
echo ""
echo "💡 This indicates fundamental token issues"
echo ""
echo "📄 API Response:"
cat /tmp/user_response.json
exit 1
fi

- name: Validation Summary
if: always()
env:
GITHUB_BASE_URL: ${{ inputs.github_base_url }}
GITHUB_ORG: ${{ inputs.github_org }}
run: |
echo ""
echo "🎯 Validation Summary"
echo "===================="
echo ""
echo "✅ If all tests passed, your token should work with patcher-action!"
echo ""
echo "📋 Next Steps:"
echo " 1. Use the same token in your patcher-action workflow"
echo " 2. Use the same github_base_url: ${GITHUB_BASE_URL}"
echo " 3. Use the same github_org: ${GITHUB_ORG}"
echo ""
echo "❓ If you encountered issues:"
echo " 1. Review the error messages above"
echo " 2. Check the Solutions sections for each failed test"
echo " 3. Contact [email protected] if you're a Gruntwork customer"
Loading