skip to Main Content

I want to automate the process of installing GitHub Actions runner on ubuntu machines on EC2 instances.

The instructions on github are as follows:

# Create a folder
$ mkdir actions-runner && cd actions-runner
# Download the latest runner package
$ curl -o actions-runner-linux-x64-2.303.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.303.0/actions-runner-linux-x64-2.303.0.tar.gz
# Optional: Validate the hash
$ echo "e4a9fb7269c1a156eb5d5369232d0cd62e06bec2fd2b321600e85ac914a9cc73  actions-runner-linux-x64-2.303.0.tar.gz" | shasum -a 256 -c
# Extract the installer
$ tar xzf ./actions-runner-linux-x64-2.303.0.tar.gz
# Create the runner and start the configuration experience
$ ./config.sh --url https://github.com/MyOrg/MyRepo --token [REDACTED]
# Last step, run it!
$ ./run.sh

However the token is different each time I check these instructions.

How can I create a user-data like section (or a launch template for my autoscaling group) in a repeatable fashion so that I don’t have to check for a new token each time?

TL;DR: If I destroy the EC2 instance and recreate it, will the same token apply for registering the machine as a runner?

2

Answers


  1. Chosen as BEST ANSWER

    I found out that this works

    ./config.sh --unattended --url '${github_repo_url}' --pat '"$GITHUB_PAT"' --name '${name}' --labels '${labels}' --replace
    

    The GITHUB_PAT needs to be a personall access token with repo scope at least.


  2. Are you able to figure this out? I am trying to find the same thing. In my case the EC2 instance is in AutoScaling group.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search