Skip to content

Failed to run Github Actions self-hosted on CodeBuild

0

Context

I'm configuring self-hosted Github Actions runner on CodeBuild. The repository is a private repo in my organization.

Issue

Github Actions Runner does not spin up

Log

Failed to create webhook. GitHub API limit reached or permission issue encountered when creating the webhook. Troubleshooting guide: https://docs.aws.amazon.com/codebuild/latest/userguide/connections-github-app.html#connections-github-troubleshooting

Authentication

Using fine-grained PAT. I set owner of PAT to the organization and the PAT is approved. The PAT is not expired and has following permissions:

  • Repositories scope:
    • Contents: Read-only
    • Commit statuses
    • Webhooks: Read and write
    • Pull requests: Read-only
    • Administration: Read and write

Organization scope:

  • Webhooks: Read-only

IAM Role

Added AWSCodeBuildDeveloperAccess and some extra policies to access S3.

Actions configuration

runs-on:
  - codebuild-${{project_name}}-${{ github.run_id }}-${{ github.run_attempt }}

What is the root cause and how to fix?

asked 9 months ago227 views

3 Answers
0

The issue with your GitHub Actions self-hosted runner on CodeBuild not spinning up appears to be related to authentication problems. Based on the error message, there are a few potential root causes:

  1. Insufficient Permissions: While you've added several permissions to your Personal Access Token (PAT), you might be missing some required permissions. For GitHub Actions integration with CodeBuild, ensure your PAT has:
  • Read permissions for deployments and actions within GitHub
  • Appropriate access to the organization repositories
  1. Project Name Mismatch: If the project name in your GitHub Actions workflow YAML doesn't exactly match the name of the CodeBuild project you created, CodeBuild won't process the webhook and the GitHub Actions workflow might hang.

  2. Authentication Token Issues: Your PAT might not be properly configured or recognized. Since you're using an organization repository, ensure that:

  • The PAT is still valid and not expired
  • The GitHub user associated with the PAT has not been removed from the organization

To fix these issues:

  1. Verify that your CodeBuild project name exactly matches what's referenced in your GitHub Actions workflow YAML.

  2. Check if your PAT has all necessary permissions, particularly read permissions for deployments and actions.

  3. Ensure the GitHub user associated with the PAT is still part of the organization and has appropriate access.

  4. Consider using an alternative authentication method like OAuth or CodeConnections if PAT continues to cause issues.

  5. Use the GitHub API to debug webhook deliveries to see exactly what's happening when the webhook is triggered.

If you're hitting API rate limits as suggested in the error message, you may need to wait before trying again or optimize your setup to reduce API calls.
Sources
Self-hosted GitHub Actions runners in AWS CodeBuild - AWS CodeBuild
Troubleshoot the webhook - AWS CodeBuild
Tutorial: Configure a CodeBuild-hosted GitHub Actions runner - AWS CodeBuild
Resolve authentication errors during CodeBuild GitHub Actions integration | AWS re:Post

answered 9 months ago

0

Hi Hikouki,

Your fine‑grained PAT does not include all permissions required for CodeBuild to create the webhook. CodeBuild creates GitHub webhooks via the GitHub App/Connection, and this operation requires broader permissions than a fine‑grained PAT provides.

Fine‑grained PATs cannot grant Actions or Deployments permissions, which are required for CodeBuild’s webhook creation.

Additionally, PATs lack the ability to act at the organization admin level, which is needed to create repo-level webhooks for org-owned private repos.

AWS official guidance and multiple blogs emphasize that using a PAT for CodeBuild GitHub Actions runners is not recommended; you should instead use OAuth / GitHub App connection.

Ref: https://sjramblings.io/github-self-hosted-runners-on-aws-codebuild/

answered 9 months ago

0

Hi @Chandramouli, thanks for your response.

From this article, https://www.wiz.io/blog/wiz-research-codebreach-vulnerability-aws-codebuild. Seems PAT is recommended.

I want to try with PAT first. Then which permission I need to add? I added Actions and Deployment read-only to repositories scope but I don't work.

Enter image description here

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.