Announcing Cloud PAM

Baton Docs

Set up a daily check for GitHub user rights updates using Baton

Welcome! In this guide, you'll learn how to use the Baton to monitor changes in access rights at specific times. This guide will show you how to use Baton and integrate it with your GitHub instance using an AWS S3 bucket.

After reading this guide, you will be able to:

  • Understand how the Baton SDK works
  • Understand how to generate a c1z file
  • Understand how to integrate the Baton SDK with GitHub
  • Understand how to set up a GitHub scheduled flow

Let’s get started!

Before you start

Before you begin, make sure you have everything set up from the list below:

Part one: Prepare your Github access token

The Github connector allows you to manage access rights for all users across all repositories. Setting up the connector is very simple, so let’s take a look at how to do it.

  1. Create a new Github Personal Access Token with the following permissions:

    AreaScope of access
  2. Save your Personal Access Token. You will need it later.

Part two: Create an AWS S3 bucket

  1. As a next step, you need to create new AWS S3 bucket. This bucket will be used for storage of the exported file from Baton.

If you are not sure how to create an S3 bucket, check the official AWS guide on how to work with AWS S3.

  1. Once your AWS S3 is created, copy these values:
    • REGION

Now your AWS S3 account is ready to receive files from Baton. In next steps we will connect it all together.

Part three: Create GitHub Actions secrets

Because we want to use GitHub Actions for pushing access changess to AWS S3, we need to create GitHub Actions secrets first.

  1. Create a new GitHub repository

  2. Inside your GitHub repository click Settings.

  3. Select Secrets, then Actions.

  4. Add New repository secrets:

  5. At the end your GitHub should look like this:

Part four: Schedule your connector

As a practical example, we have prepared a use case where the script will run at a scheduled time every day and check for permission changes on your GitHub.

In our case, we want to check updates every day at 9AM. We will use a simple cron script to do this.

  1. Create a Github Action file .github/workflows/github-schedule.yml inside your GitHub repository.
  2. Paste the Github Action instructions to github-schedule.yml.
name: Baton Github Schedule

    - cron: "0 9 * * *"

    name: Baton diff Github permissions
    runs-on: ubuntu-latest
      - uses: actions/checkout@v3
      - run: "./.github/scripts/"
        shell: "bash"
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_BUCKET: your_s3_bucket
          AWS_REGION: your_s3_bucket_region
          BATON_ORGS: your_github_org
          BATON_TOKEN: ${{ secrets.BATON_TOKEN }}

If you need help with cron format, check out crontabguru.

  1. Paste the script below, which the Github Action will use, into a new file called .github/scripts/
set -xe

# You have to set these ENV variables to your CI/CD:
# BATON_TOKEN - your github access token
# BATON_ORGS - your github organization(s) separated by comma
# AWS_ACCESS_KEY_ID - your AWS access key
# AWS_SECRET_ACCESS_KEY - your AWS secret access key
# AWS_REGION - your AWS bucket region
# AWS_BUCKET - your AWS bucket name

# Set the output filenames
now=$(date +"%Y%m%d%H%M%S")

# Pull the containers to ensure we have access
docker pull
docker pull

# Run sync to produce c1z

# Run a diff
docker run -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_REGION -f "$c1zFile" diff
  1. Make github/scripts/ executable:
chmod +x github/scripts/

About the c1z file:

Ac1z file contains all of the information that the connector has collected as part of a synchronization process. Using the c1z utility, you can browse the contents of the sync.c1z file that is the output of a connector, including export to a .csv or .xlsx file.

  1. Commit and push your changes to your default branch.

  2. At this point, the script will automatically run at the time you set in github-schedule.yml.

What’s next?

As you’ve seen, the Baton SDK is a powerful tool that can help you monitor Github rights changes. But that’s just one example of what Baton can do.

Check out our other tutorials to discover the full potential of Baton: