npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nikovirtala/cdk-codebuild-hosted-github-actions-runner

v1.0.348

Published

A construct to create an AWS CodeBuild project that can be used to run GitHub Actions workflows

Readme

CDK Construct for CodeBuild-Hosted GitHub Actions Runner

This project provides an AWS CDK construct that creates a CodeBuild project for running GitHub Actions workflows.

The CodebuildHostedGitHubActionsRunner construct allows you to easily set up an AWS CodeBuild project that can be used as a runner for GitHub Actions. This enables you to leverage AWS infrastructure for your GitHub Actions workflows, providing a scalable and cost-effective solution for CI/CD pipelines.

Repository Structure

.
├── API.md
├── package.json
├── README.md
├── src
│   └── index.ts
└── tsconfig.dev.json
  • src/index.ts: Contains the main implementation of the CodebuildHostedGitHubActionsRunner construct.
  • package.json: Defines the project dependencies and scripts.
  • tsconfig.dev.json: TypeScript configuration for development.

Usage Instructions

Installation

To use this construct in your AWS CDK project, install it via npm:

npm install @nikovirtala/cdk-codebuild-hosted-github-actions-runner

Getting Started

Here's a basic example of how to use the CodebuildHostedGitHubActionsRunner construct in your CDK stack:

import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { CodebuildHostedGitHubActionsRunner } from '@nikovirtala/cdk-codebuild-hosted-github-actions-runner';

export class MyStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    new CodebuildHostedGitHubActionsRunner(this, 'GitHubActionsRunner', {
      repositoryOwner: 'myorg',
      repositoryName: 'myrepo',
      tokenSecretArn: 'arn:aws:secretsmanager:region:account-id:secret:my-github-token',
    });
  }
}

Configuration Options

The CodebuildHostedGitHubActionsRunner construct accepts the following properties:

  • codeBuildProjectName (optional): The name of the CodeBuild project. If not provided, a name is generated based on the repository owner and name.
  • repositoryOwner (required): The owner of the GitHub repository.
  • repositoryName (required): The name of the GitHub repository.
  • tokenSecretArn (optional): The ARN of the Secrets Manager secret containing the GitHub token. This is required if the GitHub repository is private.

Integration with GitHub Actions

To use this CodeBuild project as a runner for your GitHub Actions workflows, you'll need to configure your workflow to use self-hosted runners. Here's an example workflow:

name: My Workflow

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - name: Run a one-line script
        run: echo 'Hello, world!'

Troubleshooting

Common Issues

  1. GitHub Token Not Recognized

    • Problem: The CodeBuild project fails to authenticate with GitHub.
    • Error Message: "Unable to access the repository. Please check the source definition of your project."
    • Solution:
      1. Verify that the GitHub token is correctly stored in AWS Secrets Manager.
      2. Ensure the tokenSecretArn property is correctly set in the construct.
      3. Check if the token has the necessary permissions for the repository.
  2. CodeBuild Project Creation Fails

    • Problem: The CDK deployment fails when creating the CodeBuild project.
    • Error Message: "Resource handler returned message: "Invalid request provided" (RequestToken: ...)"
    • Solution:
      1. Check if you have the necessary permissions to create CodeBuild projects.
      2. Verify that the provided repository owner and name are correct.
      3. Ensure you're not exceeding any AWS account limits for CodeBuild projects.

Debugging

To enable verbose logging for the CDK deployment:

cdk deploy --debug

This will provide more detailed information about the deployment process and any errors encountered.

Data Flow

The CodebuildHostedGitHubActionsRunner construct sets up a CodeBuild project that integrates with GitHub Actions. Here's how the data flows through the system:

  1. GitHub Action Workflow Triggered
  2. GitHub sends a webhook event to CodeBuild
  3. CodeBuild Project receives the webhook
  4. CodeBuild Project clones the GitHub repository
  5. CodeBuild executes the GitHub Actions workflow
  6. Results are sent back to GitHub
graph TD
    A[GitHub] -->|webhook| B[CodeBuild Project]
    B -->|clone| C[GitHub Repo]
    B -->|execute workflow| D[Execute Workflow]
    D -->|results| B
    B -->|results| A

Note: If a GitHub token is provided, the construct creates a GitHub source credential in CodeBuild to allow access to private repositories.

Infrastructure

The CodebuildHostedGitHubActionsRunner construct creates the following AWS resources:

  • AWS CodeBuild Project:

    • Type: aws_codebuild.Project
    • Purpose: Runs GitHub Actions workflows
  • GitHub Source Credentials (if token provided):

    • Type: aws_codebuild.GitHubSourceCredentials
    • Purpose: Authenticates CodeBuild with GitHub for private repositories

The construct also references an existing AWS Secrets Manager secret if a tokenSecretArn is provided.