Skip to content

Repository files navigation

Gitlab Runner Action

This action starts a gitlab runner and registers it with the given gitlab instance. It can be configured to exit after the first job it receives or after a timeout.

Action Inputs

Input NameDescriptionRequiredEnum ValuesDefault Value
gitlab-instanceGitlab instanceNoN/Ahttps://gitlab.com/
registration-tokenRegistration tokenYesN/AN/A
nameRunner nameYesN/AN/A
tag-listTag list to bind with the runnerYesN/AN/A
docker-imageDocker image used by runnerNoN/Adocker:19.03.12
run-untaggedParameter that allows or not to pick untagged jobsNotrue or falsetrue
access-levelParameter to create or not a protected runnerNoref_protected or not_protectednot_protected
concurrentMaximum number of jobs that can run concurrently (automatically set to 1 if exit-after-job is true)NoN/A4
timeoutTimeout in seconds for how long the runner should stay active (ignored if exit-after-job is true)NoN/A3600
exit-after-jobExit after first job completes instead of waiting for timeout (forces concurrent to 1)Notrue or falsefalse

Example Workflows

Exit After Single Job

Exit immediately after completing one job (concurrent is automatically set to 1):

name: Gitlab Runner Serviceon: [repository_dispatch]jobs:
build:
runs-on: ubuntu-lateststeps:
- name: Gitlab Runneruses: onecommons/gitlab-runner-action@mainwith:
registration-token: "${{ secrets.GITLAB_RUNNER_TOKEN }}"name: ${{ github.run_id }}tag-list: "crosscicd"exit-after-job: "true"# concurrent will be automatically set to 1

Long-running Runner with Concurrent Jobs

Run multiple jobs concurrently with a 2-hour timeout:

name: Gitlab Runner Serviceon: [repository_dispatch]jobs:
build:
runs-on: ubuntu-latesttimeout-minutes: 130# Slightly longer than timeout for cleanupsteps:
- name: Gitlab Runneruses: onecommons/gitlab-runner-action@mainwith:
registration-token: "${{ secrets.GITLAB_RUNNER_TOKEN }}"name: ${{ github.run_id }}tag-list: "crosscicd"concurrent: "2"timeout: "7200"# 2 hours in seconds

Basic Example with Space Cleanup

This example includes a step for cleaning space and gitlab runner to provide up to 60mb for the runner.

name: Gitlab Runner Serviceon: [repository_dispatch]jobs:
build:
runs-on: ubuntu-lateststeps:
- name: Maximize Build Spaceuses: easimon/maximize-build-space@masterwith:
root-reserve-mb: 512swap-size-mb: 1024remove-dotnet: 'true'remove-android: 'true'remove-haskell: 'true'
- name: Gitlab Runneruses: onecommons/gitlab-runner-action@mainwith:
registration-token: "${{ github.event.client_payload.registration_token }}"docker-image: "docker:19.03.12"name: ${{ github.run_id }}tag-list: "crosscicd"

Triggering job via API

curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/owner/repo/dispatches \
-d '{ "event_type": "run-gitlab-runner", "client_payload": { "timeout": "3600", "concurrent": "2", "tag_list": "my-custom-tag" } }'

About

GitHub Action to run your own GitLab Runner inside a GitHub Runner

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages