├── .gitignore
├── .tool-versions
├── .github
├── FUNDING.yml
├── codeql
│ └── codeql-config.yml
└── workflows
│ ├── codeql.yaml
│ ├── stale.yml
│ ├── release.yml
│ ├── test.yml
│ ├── base.yml
│ └── deploy.yml
├── sider.yml
├── Dockerfile.base
├── .pre-commit-config.yaml
├── goss_reusage_fail.yaml
├── install_actions.sh
├── goss_full.yaml
├── renovate.json
├── goss_full_defaults.yaml
├── Dockerfile
├── SECURITY.md
├── token.sh
├── CONTRIBUTING.md
├── goss_base.yaml
├── app_token.sh
├── entrypoint.sh
├── README.md
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | *.bak
2 | .idea
3 |
--------------------------------------------------------------------------------
/.tool-versions:
--------------------------------------------------------------------------------
1 | shellcheck 0.11.0
2 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: myoung34
4 |
--------------------------------------------------------------------------------
/.github/codeql/codeql-config.yml:
--------------------------------------------------------------------------------
1 | query-filters:
2 | - include:
3 | id: actions/unpinned-tag
4 |
--------------------------------------------------------------------------------
/sider.yml:
--------------------------------------------------------------------------------
1 | linter:
2 | actionlint:
3 | ignore:
4 | - ".*Quote this to prevent word splitting.*"
5 |
--------------------------------------------------------------------------------
/Dockerfile.base:
--------------------------------------------------------------------------------
1 | FROM ubuntu:focal
2 | LABEL maintainer="myoung34@my.apsu.edu"
3 |
4 | ENV LANG=en_US.UTF-8
5 | ENV LANGUAGE=en_US.UTF-8
6 | ENV LC_ALL=en_US.UTF-8
7 | SHELL ["/bin/bash", "-o", "pipefail", "-c"]
8 | ENV DEBIAN_FRONTEND=noninteractive
9 |
10 | COPY --chmod=700 build/ /tmp/build/
11 | RUN /tmp/build/install_base.sh
12 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/pre-commit/pre-commit-hooks
3 | rev: v4.3.0
4 | hooks:
5 | - id: check-yaml
6 | exclude: goss_[a-z]*.yaml
7 | - id: end-of-file-fixer
8 | - id: trailing-whitespace
9 | - id: check-case-conflict
10 | - id: check-merge-conflict
11 | - id: detect-private-key
12 |
--------------------------------------------------------------------------------
/goss_reusage_fail.yaml:
--------------------------------------------------------------------------------
1 | command:
2 | /entrypoint.sh something:
3 | exit-status: 1
4 | stdout:
5 | - "Runner reusage is enabled"
6 | - "Reusage is enabled. Storing data to /runner/data"
7 | - "DISABLE_AUTOMATIC_DEREGISTRATION should be set to true to avoid issues with re-using a deregistered runner."
8 | stderr: ""
9 | timeout: 2000
10 |
--------------------------------------------------------------------------------
/install_actions.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash -ex
2 | GH_RUNNER_VERSION=$1
3 | TARGETPLATFORM=$2
4 |
5 | export TARGET_ARCH="x64"
6 | if [[ $TARGETPLATFORM == "linux/arm64" ]]; then
7 | export TARGET_ARCH="arm64"
8 | fi
9 | curl -L "https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-${TARGET_ARCH}-${GH_RUNNER_VERSION}.tar.gz" > actions.tar.gz
10 | tar -zxf actions.tar.gz
11 | rm -f actions.tar.gz
12 | ./bin/installdependencies.sh
13 | mkdir -p /_work
14 |
--------------------------------------------------------------------------------
/goss_full.yaml:
--------------------------------------------------------------------------------
1 | command:
2 | /entrypoint.sh something:
3 | exit-status: 0
4 | stdout:
5 | - "Runner reusage is disabled"
6 | - ""
7 | - "Disable automatic registration: true"
8 | - "Random runner suffix: true"
9 | - "Runner workdir: /tmp/a"
10 | - "Runner name: huzzah"
11 | - "Labels: blue,green"
12 | - "Runner Group: wat"
13 | - "Github Host: github.example.com"
14 | - "Run as root:true"
15 | - "Start docker: false"
16 | - "Running something"
17 | stderr: ""
18 | timeout: 2000
19 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:base",
5 | "helpers:pinGitHubActionDigests"
6 | ],
7 | "packageRules": [
8 | {
9 | "matchUpdateTypes": ["minor", "patch", "pin", "digest"],
10 | "automerge": true
11 | },
12 | {
13 | "matchDepTypes": ["devDependencies"],
14 | "automerge": true
15 | },
16 | {
17 | "matchManagers": ["github-actions"],
18 | "matchPackagePatterns": [".*"],
19 | "versioning": "digest"
20 | }
21 | ],
22 | "platformAutomerge": true
23 | }
24 |
--------------------------------------------------------------------------------
/goss_full_defaults.yaml:
--------------------------------------------------------------------------------
1 | command:
2 | /entrypoint.sh something:
3 | exit-status: 0
4 | stdout:
5 | - REPO_URL required for repo runners
6 | - Runner reusage is disabled
7 | - ""
8 | - 'Disable automatic registration: false'
9 | - 'Random runner suffix: true'
10 | - 'Runner name: test'
11 | - 'Runner workdir: /_work/test'
12 | - 'Labels: default'
13 | - 'Runner Group: Default'
14 | - 'Github Host: github.com'
15 | - Run as root:true
16 | - 'Start docker: false'
17 | - Running something
18 | - ""
19 | stderr: ""
20 | timeout: 2000
21 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # hadolint ignore=DL3007
2 | FROM myoung34/github-runner-base:latest
3 | LABEL maintainer="myoung34@my.apsu.edu"
4 |
5 | ENV AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
6 | RUN mkdir -p /opt/hostedtoolcache
7 |
8 | ARG GH_RUNNER_VERSION="2.330.0"
9 |
10 | ARG TARGETPLATFORM
11 |
12 | SHELL ["/bin/bash", "-o", "pipefail", "-c"]
13 |
14 | WORKDIR /actions-runner
15 | COPY install_actions.sh /actions-runner
16 |
17 | RUN chmod +x /actions-runner/install_actions.sh \
18 | && /actions-runner/install_actions.sh ${GH_RUNNER_VERSION} ${TARGETPLATFORM} \
19 | && rm /actions-runner/install_actions.sh \
20 | && chown runner /_work /actions-runner /opt/hostedtoolcache
21 |
22 | COPY token.sh entrypoint.sh app_token.sh /
23 | RUN chmod +x /token.sh /entrypoint.sh /app_token.sh
24 |
25 | ENTRYPOINT ["/entrypoint.sh"]
26 | CMD ["./bin/Runner.Listener", "run", "--startuptype", "service"]
27 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yaml:
--------------------------------------------------------------------------------
1 | name: CodeQL Security Analysis
2 |
3 | on:
4 | push:
5 | branches: [master]
6 |
7 | jobs:
8 | analyze:
9 | name: Analyze GitHub Actions YAML
10 | runs-on: ubuntu-latest
11 | permissions:
12 | security-events: write
13 | actions: read
14 | contents: read
15 |
16 | steps:
17 | - name: Checkout repository
18 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
19 |
20 | - name: Initialize CodeQL
21 | uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
22 | with:
23 | languages: "actions"
24 | queries: security-extended
25 | config-file: .github/codeql/codeql-config.yml
26 |
27 | - name: Perform CodeQL Analysis
28 | uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
29 | with:
30 | category: "/language:actions"
31 |
--------------------------------------------------------------------------------
/.github/workflows/stale.yml:
--------------------------------------------------------------------------------
1 | name: 'Close stale issues and PR'
2 | on:
3 | schedule:
4 | - cron: '30 1 * * *'
5 | workflow_dispatch:
6 |
7 | permissions:
8 | issues: write
9 | pull-requests: write
10 |
11 | jobs:
12 | stale:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
16 | with:
17 | stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
18 | stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
19 | close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
20 | days-before-stale: 30
21 | days-before-close: 5
22 | days-before-pr-close: -1
23 | exempt-issue-labels: 'stale-exempt'
24 | exempt-pr-labels: 'stale-exempt'
25 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | ## Security
2 |
3 | If you believe you have found a security vulnerability, please report it to me as described below.
4 |
5 | ## Reporting Security Issues
6 |
7 | **Please do not report security vulnerabilities through public GitHub issues.** Instead, please report them to me directly at [myoung34@my.apsu.edu](mailto:myoung34@my.apsu.edu).
8 |
9 | If you'd like to communicate securely, my keybase is [here](https://keybase.io/3vilpenguin)
10 |
11 | Please include the requested information listed below (as much as you can provide) to help better understand the nature and scope of the possible issue:
12 |
13 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
14 | * Full paths of source file(s) related to the manifestation of the issue
15 | * The location of the affected source code (tag/branch/commit or direct URL)
16 | * Any special configuration required to reproduce the issue
17 | * Step-by-step instructions to reproduce the issue
18 | * Proof-of-concept or exploit code (if possible)
19 | * Impact of the issue, including how an attacker might exploit the issue
20 |
21 | ## Preferred Languages
22 |
23 | I prefer all communications to be in English.
24 |
--------------------------------------------------------------------------------
/token.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | _GITHUB_HOST=${GITHUB_HOST:="github.com"}
4 |
5 | # If URL is not github.com then use the enterprise api endpoint
6 | if [[ ${GITHUB_HOST} = "github.com" ]]; then
7 | URI="https://api.${_GITHUB_HOST}"
8 | else
9 | URI="https://${_GITHUB_HOST}/api/v3"
10 | fi
11 |
12 | API_VERSION=v3
13 | API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
14 | AUTH_HEADER="Authorization: token ${ACCESS_TOKEN}"
15 | CONTENT_LENGTH_HEADER="Content-Length: 0"
16 |
17 | case ${RUNNER_SCOPE} in
18 | org*)
19 | _FULL_URL="${URI}/orgs/${ORG_NAME}/actions/runners/registration-token"
20 | ;;
21 |
22 | ent*)
23 | _FULL_URL="${URI}/enterprises/${ENTERPRISE_NAME}/actions/runners/registration-token"
24 | ;;
25 |
26 | *)
27 | _PROTO="https://"
28 | # shellcheck disable=SC2116
29 | _URL="$(echo "${REPO_URL/${_PROTO}/}")"
30 | _PATH="$(echo "${_URL}" | grep / | cut -d/ -f2-)"
31 | _ACCOUNT="$(echo "${_PATH}" | cut -d/ -f1)"
32 | _REPO="$(echo "${_PATH}" | cut -d/ -f2)"
33 | _FULL_URL="${URI}/repos/${_ACCOUNT}/${_REPO}/actions/runners/registration-token"
34 | ;;
35 | esac
36 |
37 | RUNNER_TOKEN="$(curl -XPOST -fsSL \
38 | -H "${CONTENT_LENGTH_HEADER}" \
39 | -H "${AUTH_HEADER}" \
40 | -H "${API_HEADER}" \
41 | "${_FULL_URL}" \
42 | | jq -r '.token')"
43 |
44 | echo "{\"token\": \"${RUNNER_TOKEN}\", \"full_url\": \"${_FULL_URL}\"}"
45 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to docker-github-actions-runner
2 |
3 | Thank you for your interest in contributing to `docker-github-actions-runner`! This guide is designed to make your contribution experience smooth and effective. Let's work together to make this project even better!
4 |
5 | ## Table of Contents
6 | - [Code of Conduct](#code-of-conduct)
7 | - [Issues](#issues)
8 | - [Before Creating an Issue](#before-creating-an-issue)
9 | - [Contribute to the Wiki](#contribute-to-the-wiki)
10 |
11 | ## Code of Conduct
12 |
13 | We aim to foster a welcoming and inclusive environment for all contributors. Here are some guidelines to keep in mind:
14 |
15 | - **Be Respectful**: Treat everyone with kindness and respect. Avoid making assumptions or passing judgments.
16 | - **Do Your Research**: Before asking or contributing, take a moment to research. It's possible that your question or issue has already been addressed.
17 | - **Value Everyone's Time**: Please understand that the maintainers and contributors have other commitments. While we're always eager to help, addressing certain nuances might require external contributions. However, we're here to guide and assist you.
18 |
19 | ## Issues
20 |
21 | ### Before Creating an Issue
22 |
23 | 1. **Search Existing Issues**: Before creating a new issue, please [check if a similar issue already exists](https://github.com/myoung34/docker-github-actions-runner/issues). This helps in reducing duplicates and streamlining discussions.
24 | 2. **Refer to the Wiki**: The [project's wiki](https://github.com/myoung34/docker-github-actions-runner/wiki) is a valuable resource. It might have the information or solution you're seeking.
25 |
26 | ## Contribute to the Wiki
27 |
28 | The [wiki](https://github.com/myoung34/docker-github-actions-runner/wiki) is a collaborative space for the community. You're encouraged to share knowledge, tips, and best practices related to `docker-github-actions-runner`. Your contributions can help others and enhance the overall quality of the wiki.
29 |
--------------------------------------------------------------------------------
/goss_base.yaml:
--------------------------------------------------------------------------------
1 | package:
2 | curl:
3 | installed: true
4 | docker:
5 | installed: false
6 | docker-compose:
7 | installed: false
8 | git:
9 | installed: true
10 | git-lfs:
11 | installed: false
12 | jq:
13 | installed: true
14 | lsb-release:
15 | installed: true
16 | make:
17 | installed: true
18 | pwsh:
19 | installed: false
20 | python3:
21 | installed: true
22 | rsync:
23 | installed: true
24 | ssh:
25 | installed: false
26 | sudo:
27 | installed: true
28 | tar:
29 | installed: true
30 | unzip:
31 | installed: true
32 | wget:
33 | installed: true
34 | yq:
35 | installed: false
36 | # Ubuntu Focal is the only one currently that doesnt have an official upstream skopeo/buildah/podman
37 | {{ if not (eq .Vars.oscodename "focal") }}
38 | skopeo:
39 | installed: true
40 | buildah:
41 | installed: true
42 | podman:
43 | installed: true
44 | {{ end }}
45 | file:
46 | /usr/bin/gh:
47 | exists: true
48 | /usr/bin/nodejs:
49 | exists: true
50 | /usr/sbin/gosu:
51 | exists: true
52 | /usr/bin/dumb-init:
53 | exists: true
54 | /etc/init.d/docker:
55 | exists: true
56 | owner: root
57 | group: root
58 | filetype: file
59 | contents:
60 | - /^\s*# ulimit -Hn/
61 | /etc/sudoers:
62 | exists: true
63 | owner: root
64 | group: root
65 | filetype: file
66 | contents:
67 | - '/%sudo ALL=\(ALL\) NOPASSWD: ALL/'
68 | - '/Defaults env_keep = "HTTP_PROXY HTTPS_PROXY NO_PROXY FTP_PROXY http_proxy https_proxy no_proxy ftp_proxy"/'
69 | /etc/locale.gen:
70 | exists: true
71 | owner: root
72 | group: root
73 | filetype: file
74 | contents:
75 | - '/^en_US.UTF-8 UTF-8/'
76 |
77 | user:
78 | runner:
79 | exists: true
80 | uid: 1001
81 | gid: 121
82 | groups:
83 | - runner
84 | - sudo
85 | - docker
86 | group:
87 | runner:
88 | exists: true
89 | gid: 121
90 | docker:
91 | exists: true
92 | gid: 500
93 |
--------------------------------------------------------------------------------
/app_token.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Request an ACCESS_TOKEN to be used by a GitHub APP
4 | # Environment variable that need to be set up:
5 | # * APP_ID, the GitHub's app ID
6 | # * APP_PRIVATE_KEY, the content of GitHub app's private key in PEM format.
7 | # * APP_LOGIN, the login name used to install GitHub's app
8 | #
9 | # https://github.com/orgs/community/discussions/24743#discussioncomment-3245300
10 | #
11 |
12 | set -o pipefail
13 |
14 | _GITHUB_HOST=${GITHUB_HOST:="github.com"}
15 |
16 | # If URL is not github.com then use the enterprise api endpoint
17 | if [[ ${GITHUB_HOST} = "github.com" ]]; then
18 | URI="https://api.${_GITHUB_HOST}"
19 | else
20 | URI="https://${_GITHUB_HOST}/api/v3"
21 | fi
22 |
23 | API_VERSION=v3
24 | API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
25 | CONTENT_LENGTH_HEADER="Content-Length: 0"
26 | APP_INSTALLATIONS_URI="${URI}/app/installations"
27 |
28 |
29 | # JWT parameters based off
30 | # https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app
31 | #
32 | # JWT token issuance and expiration parameters
33 | JWT_IAT_DRIFT=60
34 | JWT_EXP_DELTA=600
35 |
36 | JWT_JOSE_HEADER='{
37 | "alg": "RS256",
38 | "typ": "JWT"
39 | }'
40 |
41 |
42 | build_jwt_payload() {
43 | now=$(date +%s)
44 | iat=$((now - JWT_IAT_DRIFT))
45 | jq -c \
46 | --arg iat_str "${iat}" \
47 | --arg exp_delta_str "${JWT_EXP_DELTA}" \
48 | --arg app_id_str "${APP_ID}" \
49 | '
50 | ($iat_str | tonumber) as $iat
51 | | ($exp_delta_str | tonumber) as $exp_delta
52 | | ($app_id_str | tonumber) as $app_id
53 | | .iat = $iat
54 | | .exp = ($iat + $exp_delta)
55 | | .iss = $app_id
56 | ' <<< "{}" | tr -d '\n'
57 | }
58 |
59 | base64url() {
60 | base64 | tr '+/' '-_' | tr -d '=\n'
61 | }
62 |
63 | rs256_sign() {
64 | openssl dgst -binary -sha256 -sign <(echo "$1")
65 | }
66 |
67 | request_access_token() {
68 | jwt_payload=$(build_jwt_payload)
69 | encoded_jwt_parts=$(base64url <<<"${JWT_JOSE_HEADER}").$(base64url <<<"${jwt_payload}")
70 | encoded_mac=$(echo -n "${encoded_jwt_parts}" | rs256_sign "${APP_PRIVATE_KEY}" | base64url)
71 | generated_jwt="${encoded_jwt_parts}.${encoded_mac}"
72 |
73 | auth_header="Authorization: Bearer ${generated_jwt}"
74 |
75 | app_installations_response=$(curl -sX GET \
76 | -H "${auth_header}" \
77 | -H "${API_HEADER}" \
78 | "${APP_INSTALLATIONS_URI}" \
79 | )
80 | access_token_url=$(echo "${app_installations_response}" | jq --raw-output '.[] | select (.account.login == "'"${APP_LOGIN}"'" and .app_id == '"${APP_ID}"') .access_tokens_url')
81 | curl -sX POST \
82 | -H "${CONTENT_LENGTH_HEADER}" \
83 | -H "${auth_header}" \
84 | -H "${API_HEADER}" \
85 | "${access_token_url}" | \
86 | jq --raw-output .token
87 | }
88 |
89 | request_access_token
90 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: GitHub Actions Runner in Docker - Release
2 | on:
3 | push:
4 | tags:
5 | - '*'
6 |
7 | permissions:
8 | contents: write
9 | packages: write
10 |
11 | jobs:
12 | create-release:
13 | name: Create Release
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Checkout code
17 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
18 | - name: Create Release
19 | id: create_release
20 | uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4
21 | env:
22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 | with:
24 | tag_name: ${{ github.ref }}
25 | release_name: Release ${{ github.ref }}
26 | draft: false
27 | prerelease: false
28 |
29 | ubuntu_latest_tag:
30 | runs-on: ubuntu-latest
31 | needs: create-release
32 | steps:
33 | - name: Copy Repo Files
34 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
35 | - name: get version
36 | run: echo 'TAG='${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
37 | - name: Get GitHub organization or user
38 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
39 | - name: Set up QEMU
40 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
41 | with:
42 | image: tonistiigi/binfmt:qemu-v7.0.0
43 | - name: Set up Docker Buildx
44 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
45 | - name: Update Dockerfile FROM org
46 | run: sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:latest/" Dockerfile
47 | - name: Login to DockerHub
48 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
49 | with:
50 | username: ${{ secrets.DOCKER_USER }}
51 | password: ${{ secrets.DOCKER_TOKEN }}
52 | - name: Login to GitHub Container Registry
53 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
54 | with:
55 | registry: ghcr.io
56 | username: ${{ github.actor }}
57 | password: ${{ secrets.GITHUB_TOKEN }}
58 | - name: Retry build and push
59 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
60 | with:
61 | timeout_minutes: 60
62 | max_attempts: 3
63 | command: |
64 | docker buildx build \
65 | --file Dockerfile \
66 | --platform linux/amd64,linux/arm64 \
67 | --tag ${{ env.ORG }}/github-runner:${{ env.TAG }} \
68 | --tag ghcr.io/${{ github.repository }}:${{ env.TAG }} \
69 | --push \
70 | --pull \
71 | --cache-from type=gha \
72 | --cache-to type=gha,mode=max \
73 | .
74 |
75 | ubuntu_tag:
76 | runs-on: ubuntu-latest
77 | needs: create-release
78 | strategy:
79 | matrix:
80 | release: [jammy, focal, noble]
81 | fail-fast: false
82 | steps:
83 | - name: Copy Repo Files
84 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
85 | - name: get version
86 | run: echo 'TAG='${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
87 | - name: Get GitHub organization or user
88 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
89 | - name: Set up QEMU
90 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
91 | with:
92 | image: tonistiigi/binfmt:qemu-v7.0.0
93 | - name: Set up Docker Buildx
94 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
95 | - name: Copy Dockerfile
96 | run: cp Dockerfile Dockerfile.ubuntu-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:ubuntu-${{ matrix.release }}/" Dockerfile.ubuntu-${{ matrix.release }}
97 | - name: Login to DockerHub
98 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
99 | with:
100 | username: ${{ secrets.DOCKER_USER }}
101 | password: ${{ secrets.DOCKER_TOKEN }}
102 | - name: Login to GitHub Container Registry
103 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
104 | with:
105 | registry: ghcr.io
106 | username: ${{ github.actor }}
107 | password: ${{ secrets.GITHUB_TOKEN }}
108 | - name: Retry build and push
109 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
110 | with:
111 | timeout_minutes: 60
112 | max_attempts: 3
113 | command: |
114 | docker buildx build \
115 | --file Dockerfile.ubuntu-${{ matrix.release }} \
116 | --platform linux/amd64,linux/arm64 \
117 | --tag ${{ env.ORG }}/github-runner:${{ env.TAG }}-ubuntu-${{ matrix.release }} \
118 | --tag ghcr.io/${{ github.repository }}:${{ env.TAG }}-ubuntu-${{ matrix.release }} \
119 | --push \
120 | --pull \
121 | --cache-from type=gha \
122 | --cache-to type=gha,mode=max \
123 | .
124 | debian_tag:
125 | runs-on: ubuntu-latest
126 | strategy:
127 | matrix:
128 | release: [bookworm, trixie]
129 | fail-fast: false
130 | needs: create-release
131 | steps:
132 | - name: Copy Repo Files
133 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
134 | - name: get version
135 | run: echo 'TAG='${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
136 | - name: Get GitHub organization or user
137 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
138 | - name: Set up QEMU
139 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
140 | with:
141 | image: tonistiigi/binfmt:qemu-v7.0.0
142 | - name: Set up Docker Buildx
143 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
144 | - name: Copy Dockerfile
145 | run: cp Dockerfile Dockerfile.debian-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:debian-${{ matrix.release }}/" Dockerfile.debian-${{ matrix.release }}
146 | - name: Login to DockerHub
147 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
148 | with:
149 | username: ${{ secrets.DOCKER_USER }}
150 | password: ${{ secrets.DOCKER_TOKEN }}
151 | - name: Login to GitHub Container Registry
152 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
153 | with:
154 | registry: ghcr.io
155 | username: ${{ github.actor }}
156 | password: ${{ secrets.GITHUB_TOKEN }}
157 | - name: Retry build and push
158 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
159 | with:
160 | timeout_minutes: 60
161 | max_attempts: 3
162 | command: |
163 | docker buildx build \
164 | --file Dockerfile.debian-${{ matrix.release }} \
165 | --platform linux/amd64,linux/arm64 \
166 | --tag ${{ env.ORG }}/github-runner:${{ env.TAG }}-debian-${{ matrix.release }} \
167 | --tag ghcr.io/${{ github.repository }}:${{ env.TAG }}-debian-${{ matrix.release }} \
168 | --push \
169 | --pull \
170 | --cache-from type=gha \
171 | --cache-to type=gha,mode=max \
172 | .
173 |
--------------------------------------------------------------------------------
/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/dumb-init /bin/bash
2 | # shellcheck shell=bash
3 |
4 | export RUNNER_ALLOW_RUNASROOT=1
5 | export PATH=${PATH}:/actions-runner
6 |
7 | # Un-export these, so that they must be passed explicitly to the environment of
8 | # any command that needs them. This may help prevent leaks.
9 | export -n ACCESS_TOKEN
10 | export -n RUNNER_TOKEN
11 | export -n APP_ID
12 | export -n APP_PRIVATE_KEY
13 |
14 | trap_with_arg() {
15 | func="$1" ; shift
16 | for sig ; do
17 | # shellcheck disable=SC2064
18 | trap "$func $sig" "$sig"
19 | done
20 | }
21 |
22 | deregister_runner() {
23 | echo "Caught $1 - Deregistering runner"
24 | if [[ -n "${ACCESS_TOKEN}" ]]; then
25 | # If using GitHub App authentication, refresh the access token before deregistration
26 | if [[ -n "${APP_ID}" ]] && [[ -n "${APP_PRIVATE_KEY}" ]] && [[ -n "${APP_LOGIN}" ]]; then
27 | echo "Refreshing access token for deregistration"
28 | nl="
29 | "
30 | NEW_ACCESS_TOKEN=$(APP_ID="${APP_ID}" APP_PRIVATE_KEY="${APP_PRIVATE_KEY//\\n/${nl}}" APP_LOGIN="${APP_LOGIN}" bash /app_token.sh)
31 | if [[ -z "${NEW_ACCESS_TOKEN}" ]] || [[ "${NEW_ACCESS_TOKEN}" == "null" ]]; then
32 | echo "ERROR: Failed to refresh access token for deregistration"
33 | exit 1
34 | fi
35 | ACCESS_TOKEN="${NEW_ACCESS_TOKEN}"
36 | echo "Access token refreshed successfully"
37 | fi
38 | _TOKEN=$(ACCESS_TOKEN="${ACCESS_TOKEN}" bash /token.sh)
39 | RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
40 | fi
41 | ./config.sh remove --token "${RUNNER_TOKEN}"
42 | [[ -f "/actions-runner/.runner" ]] && rm -f /actions-runner/.runner
43 | exit
44 | }
45 |
46 | _DEBUG_ONLY=${DEBUG_ONLY:-false}
47 | _DEBUG_OUTPUT=${DEBUG_OUTPUT:-false}
48 | _DISABLE_AUTOMATIC_DEREGISTRATION=${DISABLE_AUTOMATIC_DEREGISTRATION:-false}
49 |
50 | _RANDOM_RUNNER_SUFFIX=${RANDOM_RUNNER_SUFFIX:="true"}
51 |
52 | _RUNNER_NAME=${RUNNER_NAME:-${RUNNER_NAME_PREFIX:-github-runner}-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')}
53 | if [[ ${RANDOM_RUNNER_SUFFIX} != "true" ]]; then
54 | # In some cases this file does not exist
55 | if [[ -f "/etc/hostname" ]]; then
56 | # in some cases it can also be empty
57 | if [[ $(stat --printf="%s" /etc/hostname) -ne 0 ]]; then
58 | _RUNNER_NAME_PREFIX=${RUNNER_NAME_PREFIX-"github-runner"}
59 | _RUNNER_NAME=${RUNNER_NAME:-${_RUNNER_NAME_PREFIX:+${_RUNNER_NAME_PREFIX}-}$(cat /etc/hostname)}
60 | echo "RANDOM_RUNNER_SUFFIX is ${RANDOM_RUNNER_SUFFIX}. /etc/hostname exists and has content. Setting runner name to ${_RUNNER_NAME}"
61 | else
62 | echo "RANDOM_RUNNER_SUFFIX is ${RANDOM_RUNNER_SUFFIX} ./etc/hostname exists but is empty. Not using /etc/hostname."
63 | fi
64 | else
65 | echo "RANDOM_RUNNER_SUFFIX is ${RANDOM_RUNNER_SUFFIX} but /etc/hostname does not exist. Not using /etc/hostname."
66 | fi
67 | fi
68 |
69 | _RUNNER_WORKDIR=${RUNNER_WORKDIR:-/_work/${_RUNNER_NAME}}
70 | _LABELS=${LABELS:-default}
71 | _RUNNER_GROUP=${RUNNER_GROUP:-Default}
72 | _GITHUB_HOST=${GITHUB_HOST:="github.com"}
73 | _RUN_AS_ROOT=${RUN_AS_ROOT:="true"}
74 | _START_DOCKER_SERVICE=${START_DOCKER_SERVICE:="false"}
75 | _UNSET_CONFIG_VARS=${UNSET_CONFIG_VARS:="false"}
76 | _CONFIGURED_ACTIONS_RUNNER_FILES_DIR=${CONFIGURED_ACTIONS_RUNNER_FILES_DIR:-""}
77 |
78 | # ensure backwards compatibility
79 | if [[ -z ${RUNNER_SCOPE} ]]; then
80 | if [[ ${ORG_RUNNER} == "true" ]]; then
81 | echo 'ORG_RUNNER is now deprecated. Please use RUNNER_SCOPE="org" instead.'
82 | export RUNNER_SCOPE="org"
83 | else
84 | export RUNNER_SCOPE="repo"
85 | fi
86 | fi
87 |
88 | RUNNER_SCOPE="${RUNNER_SCOPE,,}" # to lowercase
89 |
90 | case ${RUNNER_SCOPE} in
91 | org*)
92 | [[ -z ${ORG_NAME} ]] && ( echo "ORG_NAME required for org runners"; exit 1 )
93 | _SHORT_URL="https://${_GITHUB_HOST}/${ORG_NAME}"
94 | RUNNER_SCOPE="org"
95 | if [[ -n "${APP_ID}" ]] && [[ -z "${APP_LOGIN}" ]]; then
96 | APP_LOGIN=${ORG_NAME}
97 | fi
98 | ;;
99 |
100 | ent*)
101 | [[ -z ${ENTERPRISE_NAME} ]] && ( echo "ENTERPRISE_NAME required for enterprise runners"; exit 1 )
102 | _SHORT_URL="https://${_GITHUB_HOST}/enterprises/${ENTERPRISE_NAME}"
103 | RUNNER_SCOPE="enterprise"
104 | ;;
105 |
106 | *)
107 | [[ -z ${REPO_URL} ]] && ( echo "REPO_URL required for repo runners"; exit 1 )
108 | _SHORT_URL=${REPO_URL}
109 | RUNNER_SCOPE="repo"
110 | if [[ -n "${APP_ID}" ]] && [[ -z "${APP_LOGIN}" ]]; then
111 | APP_LOGIN=${REPO_URL%/*}
112 | APP_LOGIN=${APP_LOGIN##*/}
113 | fi
114 | ;;
115 | esac
116 |
117 | configure_runner() {
118 | ARGS=()
119 | if [[ -n "${APP_ID}" ]] && [[ -n "${APP_PRIVATE_KEY}" ]] && [[ -n "${APP_LOGIN}" ]]; then
120 | if [[ -n "${ACCESS_TOKEN}" ]] || [[ -n "${RUNNER_TOKEN}" ]]; then
121 | echo "ERROR: ACCESS_TOKEN or RUNNER_TOKEN provided but are mutually exclusive with APP_ID, APP_PRIVATE_KEY and APP_LOGIN." >&2
122 | exit 1
123 | fi
124 | echo "Obtaining access token for app_id ${APP_ID} and login ${APP_LOGIN}"
125 | nl="
126 | "
127 | ACCESS_TOKEN=$(APP_ID="${APP_ID}" APP_PRIVATE_KEY="${APP_PRIVATE_KEY//\\n/${nl}}" APP_LOGIN="${APP_LOGIN}" bash /app_token.sh)
128 | elif [[ -n "${APP_ID}" ]] || [[ -n "${APP_PRIVATE_KEY}" ]] || [[ -n "${APP_LOGIN}" ]]; then
129 | echo "ERROR: All of APP_ID, APP_PRIVATE_KEY and APP_LOGIN must be specified." >&2
130 | exit 1
131 | fi
132 |
133 | if [[ -n "${ACCESS_TOKEN}" ]]; then
134 | echo "Obtaining the token of the runner"
135 | _TOKEN=$(ACCESS_TOKEN="${ACCESS_TOKEN}" bash /token.sh)
136 | RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
137 | fi
138 |
139 | # shellcheck disable=SC2153
140 | if [ -n "${EPHEMERAL}" ]; then
141 | echo "Ephemeral option is enabled"
142 | ARGS+=("--ephemeral")
143 | fi
144 |
145 | if [ -n "${DISABLE_AUTO_UPDATE}" ]; then
146 | echo "Disable auto update option is enabled"
147 | ARGS+=("--disableupdate")
148 | fi
149 |
150 | if [ -n "${NO_DEFAULT_LABELS}" ]; then
151 | echo "Disable adding the default self-hosted, platform, and architecture labels"
152 | ARGS+=("--no-default-labels")
153 | fi
154 |
155 | echo "Configuring"
156 | ./config.sh \
157 | --url "${_SHORT_URL}" \
158 | --token "${RUNNER_TOKEN}" \
159 | --name "${_RUNNER_NAME}" \
160 | --work "${_RUNNER_WORKDIR}" \
161 | --labels "${_LABELS}" \
162 | --runnergroup "${_RUNNER_GROUP}" \
163 | --unattended \
164 | --replace \
165 | "${ARGS[@]}"
166 |
167 | [[ ! -d "${_RUNNER_WORKDIR}" ]] && mkdir -p "${_RUNNER_WORKDIR}"
168 |
169 | }
170 |
171 | unset_config_vars() {
172 | echo "Unsetting configuration environment variables"
173 | unset RUN_AS_ROOT
174 | unset RUNNER_NAME
175 | unset RUNNER_NAME_PREFIX
176 | unset RANDOM_RUNNER_SUFFIX
177 | unset ACCESS_TOKEN
178 | unset APP_ID
179 | unset APP_PRIVATE_KEY
180 | unset APP_LOGIN
181 | unset RUNNER_SCOPE
182 | unset ORG_NAME
183 | unset ENTERPRISE_NAME
184 | unset LABELS
185 | unset REPO_URL
186 | unset RUNNER_TOKEN
187 | unset RUNNER_WORKDIR
188 | unset RUNNER_GROUP
189 | unset GITHUB_HOST
190 | unset DISABLE_AUTOMATIC_DEREGISTRATION
191 | unset CONFIGURED_ACTIONS_RUNNER_FILES_DIR
192 | unset EPHEMERAL
193 | unset DISABLE_AUTO_UPDATE
194 | unset START_DOCKER_SERVICE
195 | unset NO_DEFAULT_LABELS
196 | unset UNSET_CONFIG_VARS
197 | }
198 |
199 | # Opt into runner reusage because a value was given
200 | if [[ -n "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
201 | echo "Runner reusage is enabled"
202 |
203 | # directory exists, copy the data
204 | if [[ -d "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
205 | echo "Copying previous data"
206 | cp -p -r "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}/." "/actions-runner"
207 | fi
208 |
209 | if [ -f "/actions-runner/.runner" ]; then
210 | echo "The runner has already been configured"
211 | else
212 |
213 | if [[ ${_DEBUG_ONLY} == "false" ]]; then
214 | configure_runner
215 | fi
216 | fi
217 | else
218 | echo "Runner reusage is disabled"
219 | if [[ ${_DEBUG_ONLY} == "false" ]]; then
220 | [[ -f "/actions-runner/.runner" ]] && rm -f /actions-runner/.runner
221 | configure_runner
222 | fi
223 | fi
224 |
225 | if [[ -n "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
226 | echo "Reusage is enabled. Storing data to ${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
227 | if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
228 | echo "DISABLE_AUTOMATIC_DEREGISTRATION should be set to true to avoid issues with re-using a deregistered runner."
229 | exit 1
230 | fi
231 | # Quoting (even with double-quotes) the regexp brokes the copying
232 | cp -p -r "/actions-runner/_diag" "/actions-runner/svc.sh" /actions-runner/.[^.]* "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
233 | fi
234 |
235 |
236 |
237 | if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
238 | if [[ ${_DEBUG_ONLY} == "false" ]]; then
239 | trap_with_arg deregister_runner SIGINT SIGQUIT SIGTERM INT TERM QUIT
240 | fi
241 | fi
242 |
243 | # Start docker service if needed (e.g. for docker-in-docker)
244 | if [[ ${_START_DOCKER_SERVICE} == "true" ]]; then
245 | echo "Starting docker service"
246 | _PREFIX=""
247 | [[ ${_RUN_AS_ROOT} != "true" ]] && _PREFIX="sudo"
248 |
249 | if [[ ${_DEBUG_ONLY} == "true" ]]; then
250 | echo ${_PREFIX} service docker start
251 | else
252 | ${_PREFIX} service docker start
253 | fi
254 | fi
255 |
256 | # Unset configuration environment variables if the flag is set
257 | if [[ ${_UNSET_CONFIG_VARS} == "true" ]]; then
258 | unset_config_vars
259 | fi
260 |
261 | # Container's command (CMD) execution as runner user
262 |
263 |
264 | if [[ ${_DEBUG_ONLY} == "true" ]] || [[ ${_DEBUG_OUTPUT} == "true" ]] ; then
265 | echo ""
266 | echo "Disable automatic registration: ${_DISABLE_AUTOMATIC_DEREGISTRATION}"
267 | echo "Random runner suffix: ${_RANDOM_RUNNER_SUFFIX}"
268 | echo "Runner name: ${_RUNNER_NAME}"
269 | echo "Runner workdir: ${_RUNNER_WORKDIR}"
270 | echo "Labels: ${_LABELS}"
271 | echo "Runner Group: ${_RUNNER_GROUP}"
272 | echo "Github Host: ${_GITHUB_HOST}"
273 | echo "Run as root:${_RUN_AS_ROOT}"
274 | echo "Start docker: ${_START_DOCKER_SERVICE}"
275 | fi
276 |
277 | if [[ ${_RUN_AS_ROOT} == "true" ]]; then
278 | if [[ $(id -u) -eq 0 ]]; then
279 | if [[ ${_DEBUG_ONLY} == "true" ]] || [[ ${_DEBUG_OUTPUT} == "true" ]] ; then
280 | # shellcheck disable=SC2145
281 | echo "Running $@"
282 | fi
283 | if [[ ${_DEBUG_ONLY} == "false" ]]; then
284 | "$@"
285 | fi
286 | else
287 | echo "ERROR: RUN_AS_ROOT env var is set to true but the user has been overridden and is not running as root, but UID '$(id -u)'"
288 | exit 1
289 | fi
290 | else
291 | if [[ $(id -u) -eq 0 ]]; then
292 | [[ -n "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]] && chown -R runner "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
293 | chown -R runner "${_RUNNER_WORKDIR}" /actions-runner
294 | # The toolcache is not recursively chowned to avoid recursing over prepulated tooling in derived docker images
295 | chown runner /opt/hostedtoolcache/
296 | if [[ ${_DEBUG_ONLY} == "true" ]] || [[ ${_DEBUG_OUTPUT} == "true" ]] ; then
297 | # shellcheck disable=SC2145
298 | echo "Running /usr/sbin/gosu runner $@"
299 | fi
300 | if [[ ${_DEBUG_ONLY} == "false" ]]; then
301 | /usr/sbin/gosu runner "$@"
302 | fi
303 | else
304 | if [[ ${_DEBUG_ONLY} == "true" ]] || [[ ${_DEBUG_OUTPUT} == "true" ]] ; then
305 | # shellcheck disable=SC2145
306 | echo "Running $@"
307 | fi
308 | if [[ ${_DEBUG_ONLY} == "false" ]]; then
309 | "$@"
310 | fi
311 | fi
312 | fi
313 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request:
3 |
4 | name: "Trigger: Push action"
5 |
6 | jobs:
7 | tests:
8 | name: Lint
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
12 | - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
13 | - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
14 | - name: Run ShellCheck
15 | uses: ludeeus/action-shellcheck@00b27aa7cb85167568cb48a3838b75f4265f2bca # master
16 |
17 | ubuntu_tests:
18 | runs-on: ubuntu-latest
19 | strategy:
20 | matrix:
21 | release: [jammy, focal, noble]
22 | platform: [amd64, arm64]
23 | fail-fast: false
24 | steps:
25 | - name: Copy Repo Files
26 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
27 | - name: Get GitHub organization or user
28 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
29 | - name: Set up QEMU
30 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
31 | with:
32 | image: tonistiigi/binfmt:qemu-v7.0.0
33 | - name: Set up Docker Buildx
34 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
35 | - name: Install Goss and dgoss
36 | run: |
37 | curl -fsSL https://goss.rocks/install | sh
38 | export PATH=$PATH:/usr/local/bin
39 | - name: Get current Git SHA
40 | id: vars
41 | run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
42 | - name: set testable image environment variable
43 | id: testvars
44 | run: echo "GH_RUNNER_IMAGE=ubuntu-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
45 | - name: Combine Dockerfile
46 | run: |
47 | cp Dockerfile.base Dockerfile.final.ubuntu-${{ matrix.release }};
48 | sed -i.bak 's/FROM.*/FROM ubuntu:${{ matrix.release }}/' Dockerfile.final.ubuntu-${{ matrix.release }}
49 |
50 | # Combine the dockerfiles
51 | cp Dockerfile Dockerfile.ubuntu-${{ matrix.release }}
52 | cat Dockerfile.ubuntu-${{ matrix.release }} | sed "s/^FROM.*//" >>Dockerfile.final.ubuntu-${{ matrix.release }}
53 |
54 | # Sanity check
55 | grep FROM Dockerfile.final.ubuntu-${{ matrix.release }}
56 | - name: Retry build final image
57 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
58 | with:
59 | timeout_minutes: 60
60 | max_attempts: 3
61 | command: |
62 | docker buildx build \
63 | --file Dockerfile.final.ubuntu-${{ matrix.release }} \
64 | --platform linux/${{ matrix.platform }} \
65 | --tag ${{ env.GH_RUNNER_IMAGE }} \
66 | --load \
67 | --cache-from type=gha \
68 | --cache-to type=gha,mode=max \
69 | .
70 | # Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}`
71 | - name: Run goss tests
72 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
73 | with:
74 | timeout_minutes: 60
75 | max_attempts: 3
76 | command: |
77 | echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
78 | echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
79 | echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
80 | # test the edge case from deregistration on reusable runners
81 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
82 | -e DEBUG_ONLY=true \
83 | -e ACCESS_TOKEN=notreal \
84 | -e LABELS=linux,x64 \
85 | -e REPO_URL=https://github.com/octokode/test1 \
86 | -e RUNNER_NAME=sustainjane-runner-1 \
87 | -e RUNNER_SCOPE=repo \
88 | -e RUNNER_WORKDIR=/tmp/runner/work \
89 | -e DISABLE_AUTOMATIC_DEREGISTRATION=false \
90 | -e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
91 | ${GH_RUNNER_IMAGE} 10
92 | if [ $? -ne 0 ]; then
93 | exit 1
94 | fi
95 | # test the base
96 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
97 | if [ $? -ne 0 ]; then
98 | exit 1
99 | fi
100 | # test the final image but with all defaults
101 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
102 | if [ $? -ne 0 ]; then
103 | exit 1
104 | fi
105 | # test the final image but with non-default values
106 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
107 | -e DEBUG_ONLY=true \
108 | -e RUNNER_NAME=huzzah \
109 | -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \
110 | -e RUN_AS_ROOT=true \
111 | -e RUNNER_NAME_PREFIX=asdf \
112 | -e ACCESS_TOKEN=1234 \
113 | -e APP_ID=5678 \
114 | -e APP_PRIVATE_KEY=2345 \
115 | -e APP_LOGIN=SOMETHING \
116 | -e RUNNER_SCOPE=org \
117 | -e ORG_NAME=myoung34 \
118 | -e ENTERPRISE_NAME=emyoung34 \
119 | -e LABELS=blue,green \
120 | -e RUNNER_TOKEN=3456 \
121 | -e RUNNER_WORKDIR=/tmp/a \
122 | -e RUNNER_GROUP=wat \
123 | -e GITHUB_HOST=github.example.com \
124 | -e DISABLE_AUTOMATIC_DEREGISTRATION=true \
125 | -e EPHEMERAL=true \
126 | -e DISABLE_AUTO_UPDATE=true \
127 | ${GH_RUNNER_IMAGE} 10
128 | if [ $? -ne 0 ]; then
129 | exit 1
130 | fi
131 | debian_tests:
132 | runs-on: ubuntu-latest
133 | strategy:
134 | matrix:
135 | release: [bookworm, trixie]
136 | platform: [amd64, arm64]
137 | fail-fast: false
138 | steps:
139 | - name: Copy Repo Files
140 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
141 | - name: Get GitHub organization or user
142 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
143 | - name: Set up QEMU
144 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
145 | with:
146 | image: tonistiigi/binfmt:qemu-v7.0.0
147 | - name: Set up Docker Buildx
148 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
149 | - name: Install Goss and dgoss
150 | run: |
151 | curl -fsSL https://goss.rocks/install | sh
152 | export PATH=$PATH:/usr/local/bin
153 | - name: Get current Git SHA
154 | id: vars
155 | run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
156 | - name: set testable image environment variable
157 | id: testvars
158 | run: echo "GH_RUNNER_IMAGE=debian-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
159 | - name: Combine Dockerfile
160 | run: |
161 | cp Dockerfile.base Dockerfile.final.debian-${{ matrix.release }}
162 | sed -i.bak 's/FROM.*/FROM debian:${{ matrix.release }}/' Dockerfile.final.debian-${{ matrix.release }}
163 |
164 | # Combine the dockerfiles
165 | cp Dockerfile Dockerfile.debian-${{ matrix.release }}
166 | cat Dockerfile.debian-${{ matrix.release }} | sed "s/^FROM.*//" >>Dockerfile.final.debian-${{ matrix.release }}
167 |
168 | # Sanity check
169 | grep FROM Dockerfile.final.debian-${{ matrix.release }}
170 | - name: Retry build final image
171 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
172 | with:
173 | timeout_minutes: 60
174 | max_attempts: 3
175 | command: |
176 | docker buildx build \
177 | --file Dockerfile.final.debian-${{ matrix.release }} \
178 | --platform linux/${{ matrix.platform }} \
179 | --tag ${{ env.GH_RUNNER_IMAGE }} \
180 | --load \
181 | --cache-from type=gha \
182 | --cache-to type=gha,mode=max \
183 | .
184 | # Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}`
185 | - name: Run goss tests
186 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
187 | with:
188 | timeout_minutes: 60
189 | max_attempts: 3
190 | command: |
191 | echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
192 | echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
193 | echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
194 | # test the edge case from deregistration on reusable runners
195 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
196 | -e DEBUG_ONLY=true \
197 | -e ACCESS_TOKEN=notreal \
198 | -e LABELS=linux,x64 \
199 | -e REPO_URL=https://github.com/octokode/test1 \
200 | -e RUNNER_NAME=sustainjane-runner-1 \
201 | -e RUNNER_SCOPE=repo \
202 | -e RUNNER_WORKDIR=/tmp/runner/work \
203 | -e DISABLE_AUTOMATIC_DEREGISTRATION=false \
204 | -e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
205 | ${GH_RUNNER_IMAGE} 10
206 | if [ $? -ne 0 ]; then
207 | exit 1
208 | fi
209 | # test the base
210 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
211 | # test the final image but with all defaults
212 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
213 | # test the final image but with non-default values
214 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
215 | -e DEBUG_ONLY=true \
216 | -e RUNNER_NAME=huzzah \
217 | -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \
218 | -e RUN_AS_ROOT=true \
219 | -e RUNNER_NAME_PREFIX=asdf \
220 | -e ACCESS_TOKEN=1234 \
221 | -e APP_ID=5678 \
222 | -e APP_PRIVATE_KEY=2345 \
223 | -e APP_LOGIN=SOMETHING \
224 | -e RUNNER_SCOPE=org \
225 | -e ORG_NAME=myoung34 \
226 | -e ENTERPRISE_NAME=emyoung34 \
227 | -e LABELS=blue,green \
228 | -e RUNNER_TOKEN=3456 \
229 | -e RUNNER_WORKDIR=/tmp/a \
230 | -e RUNNER_GROUP=wat \
231 | -e GITHUB_HOST=github.example.com \
232 | -e DISABLE_AUTOMATIC_DEREGISTRATION=true \
233 | -e EPHEMERAL=true \
234 | -e DISABLE_AUTO_UPDATE=true \
235 | ${GH_RUNNER_IMAGE} 10
236 |
--------------------------------------------------------------------------------
/.github/workflows/base.yml:
--------------------------------------------------------------------------------
1 | name: GitHub Actions Runner in Docker - Base
2 | on:
3 | push:
4 | paths:
5 | - Dockerfile.base
6 | - .github/workflows/base.yml
7 | - goss*
8 | branches:
9 | - master
10 | - develop
11 | schedule:
12 | - cron: '0 22 * * *'
13 | workflow_dispatch:
14 |
15 | jobs:
16 | ubuntu_base_tests:
17 | runs-on: ubuntu-latest
18 | strategy:
19 | matrix:
20 | release: [jammy, focal, noble]
21 | platform: [amd64, arm64]
22 | fail-fast: false
23 | steps:
24 | - name: Copy Repo Files
25 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
26 | - name: Get GitHub organization or user
27 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
28 | - name: Set up QEMU
29 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
30 | with:
31 | image: tonistiigi/binfmt:qemu-v7.0.0
32 | - name: Set up Docker Buildx
33 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
34 | - name: Copy Dockerfile
35 | run: cp Dockerfile.base Dockerfile.base.ubuntu-${{ matrix.release }}; sed -i.bak 's/FROM.*/FROM ubuntu:${{ matrix.release }}/' Dockerfile.base.ubuntu-${{ matrix.release }}
36 | - name: Install Goss and dgoss
37 | run: |
38 | curl -fsSL https://goss.rocks/install | sh
39 | export PATH=$PATH:/usr/local/bin
40 | - name: Get current Git SHA
41 | id: vars
42 | run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
43 | - name: set testable image environment variable
44 | id: testvars
45 | run: echo "GH_RUNNER_IMAGE=ubuntu-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
46 | - name: Login to DockerHub
47 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
48 | with:
49 | username: ${{ secrets.DOCKER_USER }}
50 | password: ${{ secrets.DOCKER_TOKEN }}
51 | - name: Retry build and load
52 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
53 | with:
54 | timeout_minutes: 60
55 | max_attempts: 3
56 | command: |
57 | docker buildx build \
58 | --file Dockerfile.base.ubuntu-${{ matrix.release }} \
59 | --platform linux/${{ matrix.platform }} \
60 | --tag ${{ env.GH_RUNNER_IMAGE }} \
61 | --load \
62 | --pull \
63 | --cache-from type=gha \
64 | --cache-to type=gha,mode=max \
65 | .
66 | - name: Run goss tests
67 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
68 | with:
69 | timeout_minutes: 60
70 | max_attempts: 3
71 | command: |
72 | echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
73 | echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
74 | echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
75 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
76 | if [ $? -ne 0 ]; then
77 | exit 1
78 | fi
79 |
80 | debian_base_tests:
81 | runs-on: ubuntu-latest
82 | strategy:
83 | matrix:
84 | release: [bookworm, trixie]
85 | platform: [amd64, arm64]
86 | fail-fast: false
87 | steps:
88 | - name: Copy Repo Files
89 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
90 | - name: Get GitHub organization or user
91 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
92 | - name: Set up QEMU
93 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
94 | with:
95 | image: tonistiigi/binfmt:qemu-v7.0.0
96 | - name: Set up Docker Buildx
97 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
98 | - name: Copy Dockerfile
99 | run: cp Dockerfile.base Dockerfile.base.debian-${{ matrix.release }}; sed -i.bak 's/FROM.*/FROM debian:${{ matrix.release }}/' Dockerfile.base.debian-${{ matrix.release }}
100 | - name: Install Goss and dgoss
101 | run: |
102 | curl -fsSL https://goss.rocks/install | sh
103 | export PATH=$PATH:/usr/local/bin
104 | - name: Get current Git SHA
105 | id: vars
106 | run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
107 | - name: set testable image environment variable
108 | id: testvars
109 | run: echo "GH_RUNNER_IMAGE=debian-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
110 | - name: Login to DockerHub
111 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
112 | with:
113 | username: ${{ secrets.DOCKER_USER }}
114 | password: ${{ secrets.DOCKER_TOKEN }}
115 | - name: Retry build
116 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
117 | with:
118 | timeout_minutes: 60
119 | max_attempts: 3
120 | command: |
121 | docker buildx build \
122 | --file Dockerfile.base.debian-${{ matrix.release }} \
123 | --platform linux/${{ matrix.platform }} \
124 | --tag ${{ env.GH_RUNNER_IMAGE }} \
125 | --load \
126 | --pull \
127 | --cache-from type=gha \
128 | --cache-to type=gha,mode=max \
129 | .
130 | - name: Run goss tests
131 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
132 | with:
133 | timeout_minutes: 60
134 | max_attempts: 3
135 | command: |
136 | echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
137 | echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
138 | echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
139 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
140 | if [ $? -ne 0 ]; then
141 | exit 1
142 | fi
143 |
144 |
145 | ubuntu_base_latest_deploy:
146 | runs-on: ubuntu-latest
147 | needs: ubuntu_base_tests
148 | steps:
149 | - name: Copy Repo Files
150 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
151 | - name: Get GitHub organization or user
152 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
153 | - name: Set up QEMU
154 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
155 | with:
156 | image: tonistiigi/binfmt:qemu-v7.0.0
157 | - name: Set up Docker Buildx
158 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
159 | - name: Login to DockerHub
160 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
161 | with:
162 | username: ${{ secrets.DOCKER_USER }}
163 | password: ${{ secrets.DOCKER_TOKEN }}
164 | - name: Retry build and push
165 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
166 | with:
167 | timeout_minutes: 60
168 | max_attempts: 3
169 | command: |
170 | docker buildx build \
171 | --file Dockerfile.base \
172 | --platform linux/amd64,linux/arm64 \
173 | --tag ${{ env.ORG }}/github-runner-base:latest \
174 | --push \
175 | --pull \
176 | --cache-from type=gha \
177 | --cache-to type=gha,mode=max \
178 | .
179 | ubuntu_base_deploy:
180 | runs-on: ubuntu-latest
181 | needs: ubuntu_base_tests
182 | strategy:
183 | matrix:
184 | release: [jammy, focal, noble]
185 | fail-fast: false
186 | steps:
187 | - name: Copy Repo Files
188 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
189 | - name: Get GitHub organization or user
190 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
191 | - name: Set up QEMU
192 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
193 | with:
194 | image: tonistiigi/binfmt:qemu-v7.0.0
195 | - name: Set up Docker Buildx
196 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
197 | - name: Copy Dockerfile
198 | run: cp Dockerfile.base Dockerfile.base.ubuntu-${{ matrix.release }}; sed -i.bak 's/FROM.*/FROM ubuntu:${{ matrix.release }}/' Dockerfile.base.ubuntu-${{ matrix.release }}
199 | - name: Login to DockerHub
200 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
201 | with:
202 | username: ${{ secrets.DOCKER_USER }}
203 | password: ${{ secrets.DOCKER_TOKEN }}
204 | - name: Retry build and push
205 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
206 | with:
207 | timeout_minutes: 60
208 | max_attempts: 3
209 | command: |
210 | docker buildx build \
211 | --file Dockerfile.base.ubuntu-${{ matrix.release }} \
212 | --platform linux/amd64,linux/arm64 \
213 | --tag ${{ env.ORG }}/github-runner-base:ubuntu-${{ matrix.release }} \
214 | --push \
215 | --pull \
216 | --cache-from type=gha \
217 | --cache-to type=gha,mode=max \
218 | .
219 | debian_base_deploy:
220 | runs-on: ubuntu-latest
221 | needs: debian_base_tests
222 | strategy:
223 | matrix:
224 | release: [bookworm, trixie]
225 | fail-fast: false
226 | steps:
227 | - name: Copy Repo Files
228 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
229 | - name: Get GitHub organization or user
230 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
231 | - name: Set up QEMU
232 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
233 | with:
234 | image: tonistiigi/binfmt:qemu-v7.0.0
235 | - name: Set up Docker Buildx
236 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
237 | - name: Copy Dockerfile
238 | run: cp Dockerfile.base Dockerfile.base.debian-${{ matrix.release }}; sed -i.bak 's/FROM.*/FROM debian:${{ matrix.release }}/' Dockerfile.base.debian-${{ matrix.release }}
239 | - name: Login to DockerHub
240 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
241 | with:
242 | username: ${{ secrets.DOCKER_USER }}
243 | password: ${{ secrets.DOCKER_TOKEN }}
244 | - name: Retry build and push
245 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
246 | with:
247 | timeout_minutes: 60
248 | max_attempts: 3
249 | command: |
250 | docker buildx build \
251 | --file Dockerfile.base.debian-${{ matrix.release }} \
252 | --platform linux/amd64,linux/arm64 \
253 | --tag ${{ env.ORG }}/github-runner-base:debian-${{ matrix.release }} \
254 | --push \
255 | --pull \
256 | --cache-from type=gha \
257 | --cache-to type=gha,mode=max \
258 | .
259 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Docker Github Actions Runner
2 | ============================
3 |
4 | [](https://hub.docker.com/r/myoung34/github-runner) [](https://github.com/jonico/awesome-runners)
5 |
6 | This will run the [new self-hosted github actions runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/hosting-your-own-runners).
7 |
8 | ## Quick-Start (Examples and Usage) ##
9 |
10 | Please see [the wiki](https://github.com/myoung34/docker-github-actions-runner/wiki/Usage)
11 | Please read [the contributing guidelines](https://github.com/myoung34/docker-github-actions-runner/blob/master/CONTRIBUTING.md)
12 |
13 |
14 | ## Included software and configuration ##
15 |
16 | While this project is not perfectly 1:1 with the software upstream, the included packages etc are available [here](https://github.com/myoung34/docker-github-actions-runner/blob/master/build/config.json). Documentation can be found in [the wiki](https://github.com/myoung34/docker-github-actions-runner/wiki/Usage#modifications)
17 |
18 | ## Notes ##
19 |
20 | ### Security ###
21 |
22 | It is known that environment variables are not safe from exfiltration.
23 | If you are using this runner make sure that any workflow changes are gated by a verification process (in the actions settings) so that malicious PR's cannot exfiltrate these.
24 |
25 | ### Docker Support ###
26 |
27 | Please note that while this runner installs and allows docker, github actions itself does not support using docker from a self hosted runner yet.
28 | For more information:
29 |
30 | * https://github.com/actions/runner/issues/406
31 | * https://github.com/actions/runner/issues/367
32 |
33 | Also, some GitHub Actions Workflow features, like [Job Services](https://docs.github.com/en/actions/guides/about-service-containers), won't be usable and [will result in an error](https://github.com/myoung34/docker-github-actions-runner/issues/61).
34 |
35 | ### Containerd Support ###
36 |
37 | Currently runners [do not support containerd](https://github.com/actions/runner/issues/1265)
38 |
39 | ## Docker Artifacts ##
40 |
41 | | Container Base | Supported Architectures | Tag Regex | Docker Tags | Description | Notes |
42 | | --- | --- | --- | --- | --- | --- |
43 | | ubuntu focal | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+/` `/\d\.\d{3}\.\d+-ubuntu-focal/`| [latest](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=latest) [ubuntu-focal](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=ubuntu-focal) | This is the latest build (Rebuilt nightly and on master merges). Tags without an OS name are included. Tags with `-ubuntu-focal` are included and created on [upstream tags](https://github.com/actions/runner/tags).|
44 | | ubuntu noble | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+-ubuntu-noble/` | [ubuntu-noble](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=ubuntu-noble) | This is the latest build from noble (Rebuilt nightly and on master merges). Tags with `-ubuntu-noble` are included and created on [upstream tags](https://github.com/actions/runner/tags). | |
45 | | ubuntu jammy | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+-ubuntu-jammy/` | [ubuntu-jammy](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=ubuntu-jammy) | This is the latest build from jammy (Rebuilt nightly and on master merges). Tags with `-ubuntu-jammy` are included and created on [upstream tags](https://github.com/actions/runner/tags). | There is [currently an issue with jammy from inside a 20.04LTS host](https://github.com/myoung34/docker-github-actions-runner/issues/219) which is why this is not `latest` |
46 | | debian buster (now deprecated) | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+-debian-buster/` | [debian-buster](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-buster) | Debian buster is now deprecated. The packages for arm v7 are in flux and are wildly causing build failures (git as well as liblttng-ust#. Tags with `-debian-buster` are included and created on [upstream tags](https://github.com/actions/runner/tags). | |
47 | | debian bookworm | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+-debian-bookworm/` | [debian-bookworm](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-bookworm) | This is the latest build from bookworm (Rebuilt nightly and on master merges). Tags with `-debian-bookworm` are included and created on [upstream tags](https://github.com/actions/runner/tags). | |
48 | | debian trixie | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+-debian-trixie/` | [debian-trixie](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-trixie) | This is the latest build from trixie (Rebuilt nightly and on master merges). Tags with `-debian-trixie` are included and created on [upstream tags](https://github.com/actions/runner/tags). | |
49 | | ~~debian sid~~ | `x86_64`,`arm64` | `/\d\.\d{3}\.\d+-debian-sid/` | [debian-sid](https://hub.docker.com/r/myoung34/github-runner/tags?page=1&name=debian-sid) | This is currently disabled as it is failing until `forky` is included in https://download.docker.com/linux/debian/dists/ ~~This is the latest build from sid (Rebuilt nightly and on master merges). Tags with `-debian-sid` are included and created on [upstream tags](https://github.com/actions/runner/tags).~~ | |
50 |
51 | These containers are built via Github actions that [copy the dockerfile](https://github.com/myoung34/docker-github-actions-runner/blob/master/.github/workflows/deploy.yml#L47), changing the `FROM` and building to provide simplicity.
52 |
53 | ## Environment Variables ##
54 |
55 | | Environment Variable | Description |
56 | | --- | --- |
57 | | `RUN_AS_ROOT` | Boolean to run as root. If `true`: will run as root. If `True` and the user is overridden it will error. If any other value it will run as the `runner` user and allow an optional override. Default is `true` |
58 | | `RUNNER_NAME` | The name of the runner to use. Supersedes (overrides) `RUNNER_NAME_PREFIX` |
59 | | `RUNNER_NAME_PREFIX` | A prefix for runner name (See `RANDOM_RUNNER_SUFFIX` for how the full name is generated). Note: will be overridden by `RUNNER_NAME` if provided. Defaults to `github-runner` |
60 | | `RANDOM_RUNNER_SUFFIX` | Boolean to use a randomized runner name suffix (preceded by `RUNNER_NAME_PREFIX`). Will use a 13 character random string by default. If set to a value other than true and `RUNNER_NAME_PREFIX` is set to an empty string, it will attempt to use the contents of `/etc/hostname` or fall back to a random string if the file does not exist or is empty. Note: will be overridden by `RUNNER_NAME` if provided. Defaults to `true`. |
61 | | `ACCESS_TOKEN` | A [github PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) to use to generate `RUNNER_TOKEN` dynamically at container start. Not using this requires a valid `RUNNER_TOKEN` |
62 | | `APP_ID` | The github application ID. Must be paired with `APP_PRIVATE_KEY` and should not be used with `ACCESS_TOKEN` or `RUNNER_TOKEN` |
63 | | `APP_PRIVATE_KEY` | The github application private key. Must be paired with `APP_ID` and should not be used with `ACCESS_TOKEN` or `RUNNER_TOKEN` |
64 | | `APP_LOGIN` | The github application login id. Can be paired with `APP_ID` and `APP_PRIVATE_KEY` if default value extracted from `REPO_URL` or `ORG_NAME` is not correct. Note that no default is present when `RUNNER_SCOPE` is 'enterprise'. |
65 | | `RUNNER_SCOPE` | The scope the runner will be registered on. Valid values are `repo`, `org` and `ent`. For 'org' and 'enterprise', `ACCESS_TOKEN` is required and `REPO_URL` is unnecessary. If 'org', requires `ORG_NAME`; if 'ent', requires `ENTERPRISE_NAME`. Default is 'repo'. |
66 | | `ORG_NAME` | The organization name for the runner to register under. Requires `RUNNER_SCOPE` to be 'org'. No default value. |
67 | | `ENTERPRISE_NAME` | The enterprise name for the runner to register under. Requires `RUNNER_SCOPE` to be 'enterprise'. No default value. |
68 | | `LABELS` | A comma separated string to indicate the labels. Default is 'default' |
69 | | `REPO_URL` | If using a non-organization runner this is the full repository url to register under such as 'https://github.com/myoung34/repo' |
70 | | `RUNNER_TOKEN` | If not using a PAT for `ACCESS_TOKEN` this will be the runner token provided by the Add Runner UI (a manual process). Note: This token is short lived and will change frequently. `ACCESS_TOKEN` is likely preferred. |
71 | | `RUNNER_WORKDIR` | The working directory for the runner. Runners on the same host should not share this directory. Default is '/_work'. This must match the source path for the bind-mounted volume at RUNNER_WORKDIR, in order for container actions to access files. |
72 | | `RUNNER_GROUP` | Name of the runner group to add this runner to (defaults to the default runner group) |
73 | | `GITHUB_HOST` | Optional URL of the Github Enterprise server e.g github.mycompany.com. Defaults to `github.com`. |
74 | | `DISABLE_AUTOMATIC_DEREGISTRATION` | Optional flag to disable signal catching for deregistration. Default is `false`. Any value other than exactly `false` is considered `true`. See [here](https://github.com/myoung34/docker-github-actions-runner/issues/94) |
75 | | `CONFIGURED_ACTIONS_RUNNER_FILES_DIR` | Path to use for runner data. It allows avoiding reregistration each the start of the runner. No default value. |
76 | | `EPHEMERAL` | Optional flag to configure runner with [`--ephemeral` option](https://docs.github.com/en/actions/hosting-your-own-runners/autoscaling-with-self-hosted-runners#using-ephemeral-runners-for-autoscaling). Ephemeral runners are suitable for autoscaling. |
77 | | `DISABLE_AUTO_UPDATE` | Optional environment variable to [disable auto updates](https://github.blog/changelog/2022-02-01-github-actions-self-hosted-runners-can-now-disable-automatic-updates/). Auto updates are enabled by default to preserve past behavior. Any value is considered truthy and will disable them. |
78 | | `START_DOCKER_SERVICE` | Optional flag which automatically starts the docker service if set to `true`. Useful when using [sysbox](https://github.com/nestybox/sysbox). Defaults to `false`. |
79 | | `NO_DEFAULT_LABELS` | Optional environment variable to disable adding the default self-hosted, platform, and architecture labels to the runner. Any value is considered truthy and will disable them. |
80 | | `DEBUG_ONLY` | Optional boolean to print debug output but not run any actual registration or runner commands. Used in CI and testing. Default: false |
81 | | `DEBUG_OUTPUT` | Optional boolean to print additional debug output. Default: false |
82 | | `UNSET_CONFIG_VARS` | Optional flag to unset all configuration environment variables after runner setup but before starting the runner. This prevents these variables from leaking into the workflow environment. Set to 'true' to enable. Defaults to 'false' for backward compatibility. |
83 |
84 | ## Tests ##
85 |
86 | Tests are written in [goss](https://github.com/goss-org/goss/) for general assertions.
87 | It's expected that all pull-requests have relevant assertions in order to be merged.
88 |
89 | Prereqs: Ensure that docker, goss and dgoss are set up
90 | Note: while testing locally works, github actions will test all variations of operating systems and supported architectures.
91 |
92 | The test file expects the image to test as an environment variable `GH_RUNNER_IMAGE` to assist in CI
93 |
94 | To test:
95 | ```
96 | $ # need to set minimum vars for the goss test interpolation
97 | $ echo "os: ubuntu" >goss_vars.yaml
98 | $ echo "oscodename: focal" >>goss_vars.yaml
99 | $ echo "arch: x86_64" >>goss_vars.yaml
100 | $ docker build -t my-base-test -f Dockerfile.base .
101 | $ # Use the base image in your final
102 | $ sed -i.bak 's/^FROM.*/FROM my-base-test/g' Dockerfile
103 | $ docker build -t my-full-test -f Dockerfile .
104 | $ # Run the full test from Dockerfile.base on the current git HEAD
105 | $ GOSS_VARS=goss_vars.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
106 | -e DEBUG_ONLY=true \
107 | -e RUNNER_NAME=huzzah \
108 | -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \
109 | -e RUN_AS_ROOT=true \
110 | -e RUNNER_NAME_PREFIX=asdf \
111 | -e ACCESS_TOKEN=1234 \
112 | -e APP_ID=5678 \
113 | -e APP_PRIVATE_KEY=2345 \
114 | -e APP_LOGIN=SOMETHING \
115 | -e RUNNER_SCOPE=org \
116 | -e ORG_NAME=myoung34 \
117 | -e ENTERPRISE_NAME=emyoung34 \
118 | -e LABELS=blue,green \
119 | -e RUNNER_TOKEN=3456 \
120 | -e RUNNER_WORKDIR=/tmp/a \
121 | -e RUNNER_GROUP=wat \
122 | -e GITHUB_HOST=github.example.com \
123 | -e DISABLE_AUTOMATIC_DEREGISTRATION=true \
124 | -e EPHEMERAL=true \
125 | -e DISABLE_AUTO_UPDATE=true \
126 | my-full-test 10
127 | ```
128 |
--------------------------------------------------------------------------------
/.github/workflows/deploy.yml:
--------------------------------------------------------------------------------
1 | name: GitHub Actions Runner in Docker - Latest
2 | on:
3 | push:
4 | paths-ignore:
5 | - Dockerfile.base
6 | - README.md
7 | branches:
8 | - master
9 | - develop
10 | schedule:
11 | - cron: '59 23 * * *'
12 | workflow_dispatch:
13 |
14 | permissions:
15 | contents: read
16 | packages: write
17 |
18 | jobs:
19 | ubuntu_tests:
20 | runs-on: ubuntu-latest
21 | strategy:
22 | matrix:
23 | release: [jammy, focal, noble]
24 | platform: [amd64, arm64]
25 | fail-fast: false
26 | steps:
27 | - name: Copy Repo Files
28 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
29 | - name: Get GitHub organization or user
30 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
31 | - name: Set up QEMU
32 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
33 | with:
34 | image: tonistiigi/binfmt:qemu-v7.0.0
35 | - name: Set up Docker Buildx
36 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
37 | - name: Copy Dockerfile
38 | run: cp Dockerfile Dockerfile.ubuntu-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:ubuntu-${{ matrix.release }}/" Dockerfile.ubuntu-${{ matrix.release }}
39 | - name: Install Goss and dgoss
40 | run: |
41 | curl -fsSL https://goss.rocks/install | sh
42 | export PATH=$PATH:/usr/local/bin
43 | - name: Get current Git SHA
44 | id: vars
45 | run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
46 | - name: set testable image environment variable
47 | id: testvars
48 | run: echo "GH_RUNNER_IMAGE=ubuntu-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
49 | - name: Login to DockerHub
50 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
51 | with:
52 | username: ${{ secrets.DOCKER_USER }}
53 | password: ${{ secrets.DOCKER_TOKEN }}
54 | - name: Retry build and load
55 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
56 | with:
57 | timeout_minutes: 60
58 | max_attempts: 3
59 | command: |
60 | docker buildx build \
61 | --file Dockerfile.ubuntu-${{ matrix.release }} \
62 | --platform linux/${{ matrix.platform }} \
63 | --tag ${{ env.GH_RUNNER_IMAGE }} \
64 | --load \
65 | --pull \
66 | --cache-from type=gha \
67 | --cache-to type=gha,mode=max \
68 | .
69 | # Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}`
70 | - name: Run goss tests
71 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
72 | with:
73 | timeout_minutes: 60
74 | max_attempts: 3
75 | command: |
76 | echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
77 | echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
78 | echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
79 | # test the edge case from deregistration on reusable runners
80 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
81 | -e DEBUG_ONLY=true \
82 | -e ACCESS_TOKEN=notreal \
83 | -e LABELS=linux,x64 \
84 | -e REPO_URL=https://github.com/octokode/test1 \
85 | -e RUNNER_NAME=sustainjane-runner-1 \
86 | -e RUNNER_SCOPE=repo \
87 | -e RUNNER_WORKDIR=/tmp/runner/work \
88 | -e DISABLE_AUTOMATIC_DEREGISTRATION=false \
89 | -e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
90 | ${GH_RUNNER_IMAGE} 10
91 | if [ $? -ne 0 ]; then
92 | exit 1
93 | fi
94 | # test the base
95 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
96 | if [ $? -ne 0 ]; then
97 | exit 1
98 | fi
99 | # test the final image but with all defaults
100 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
101 | if [ $? -ne 0 ]; then
102 | exit 1
103 | fi
104 | # test the final image but with non-default values
105 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
106 | -e DEBUG_ONLY=true \
107 | -e RUNNER_NAME=huzzah \
108 | -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \
109 | -e RUN_AS_ROOT=true \
110 | -e RUNNER_NAME_PREFIX=asdf \
111 | -e ACCESS_TOKEN=1234 \
112 | -e APP_ID=5678 \
113 | -e APP_PRIVATE_KEY=2345 \
114 | -e APP_LOGIN=SOMETHING \
115 | -e RUNNER_SCOPE=org \
116 | -e ORG_NAME=myoung34 \
117 | -e ENTERPRISE_NAME=emyoung34 \
118 | -e LABELS=blue,green \
119 | -e RUNNER_TOKEN=3456 \
120 | -e RUNNER_WORKDIR=/tmp/a \
121 | -e RUNNER_GROUP=wat \
122 | -e GITHUB_HOST=github.example.com \
123 | -e DISABLE_AUTOMATIC_DEREGISTRATION=true \
124 | -e EPHEMERAL=true \
125 | -e DISABLE_AUTO_UPDATE=true \
126 | ${GH_RUNNER_IMAGE} 10
127 | if [ $? -ne 0 ]; then
128 | exit 1
129 | fi
130 |
131 | debian_tests:
132 | runs-on: ubuntu-latest
133 | strategy:
134 | matrix:
135 | release: [bookworm, trixie]
136 | platform: [amd64, arm64]
137 | fail-fast: false
138 | steps:
139 | - name: Copy Repo Files
140 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
141 | - name: Get GitHub organization or user
142 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
143 | - name: Set up QEMU
144 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
145 | with:
146 | image: tonistiigi/binfmt:qemu-v7.0.0
147 | - name: Set up Docker Buildx
148 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
149 | - name: Copy Dockerfile
150 | run: cp Dockerfile Dockerfile.debian-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:debian-${{ matrix.release }}/" Dockerfile.debian-${{ matrix.release }}
151 | - name: Install Goss and dgoss
152 | run: |
153 | curl -fsSL https://goss.rocks/install | sh
154 | export PATH=$PATH:/usr/local/bin
155 | - name: Get current Git SHA
156 | id: vars
157 | run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
158 | - name: set testable image environment variable
159 | id: testvars
160 | run: echo "GH_RUNNER_IMAGE=debian-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
161 | - name: Login to DockerHub
162 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
163 | with:
164 | username: ${{ secrets.DOCKER_USER }}
165 | password: ${{ secrets.DOCKER_TOKEN }}
166 | - name: Retry build and load
167 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
168 | with:
169 | timeout_minutes: 60
170 | max_attempts: 3
171 | command: |
172 | docker buildx build \
173 | --file Dockerfile.debian-${{ matrix.release }} \
174 | --platform linux/${{ matrix.platform }} \
175 | --tag ${{ env.GH_RUNNER_IMAGE }} \
176 | --load \
177 | --pull \
178 | --cache-from type=gha \
179 | --cache-to type=gha,mode=max \
180 | .
181 | # Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}`
182 | - name: Run goss tests
183 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
184 | with:
185 | timeout_minutes: 60
186 | max_attempts: 3
187 | command: |
188 | echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
189 | echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
190 | echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
191 | # test the edge case from deregistration on reusable runners
192 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
193 | -e DEBUG_ONLY=true \
194 | -e ACCESS_TOKEN=notreal \
195 | -e LABELS=linux,x64 \
196 | -e REPO_URL=https://github.com/octokode/test1 \
197 | -e RUNNER_NAME=sustainjane-runner-1 \
198 | -e RUNNER_SCOPE=repo \
199 | -e RUNNER_WORKDIR=/tmp/runner/work \
200 | -e DISABLE_AUTOMATIC_DEREGISTRATION=false \
201 | -e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
202 | ${GH_RUNNER_IMAGE} 10
203 | if [ $? -ne 0 ]; then
204 | exit 1
205 | fi
206 | # test the base
207 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
208 | # test the final image but with all defaults
209 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
210 | # test the final image but with non-default values
211 | GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
212 | -e DEBUG_ONLY=true \
213 | -e RUNNER_NAME=huzzah \
214 | -e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \
215 | -e RUN_AS_ROOT=true \
216 | -e RUNNER_NAME_PREFIX=asdf \
217 | -e ACCESS_TOKEN=1234 \
218 | -e APP_ID=5678 \
219 | -e APP_PRIVATE_KEY=2345 \
220 | -e APP_LOGIN=SOMETHING \
221 | -e RUNNER_SCOPE=org \
222 | -e ORG_NAME=myoung34 \
223 | -e ENTERPRISE_NAME=emyoung34 \
224 | -e LABELS=blue,green \
225 | -e RUNNER_TOKEN=3456 \
226 | -e RUNNER_WORKDIR=/tmp/a \
227 | -e RUNNER_GROUP=wat \
228 | -e GITHUB_HOST=github.example.com \
229 | -e DISABLE_AUTOMATIC_DEREGISTRATION=true \
230 | -e EPHEMERAL=true \
231 | -e DISABLE_AUTO_UPDATE=true \
232 | ${GH_RUNNER_IMAGE} 10
233 |
234 | ubuntu_latest_deploy:
235 | runs-on: ubuntu-latest
236 | needs: ubuntu_tests
237 | steps:
238 | - name: Copy Repo Files
239 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
240 | - name: Get GitHub organization or user
241 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
242 | - name: Set up QEMU
243 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
244 | with:
245 | image: tonistiigi/binfmt:qemu-v7.0.0
246 | - name: Set up Docker Buildx
247 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
248 | - name: Update Dockerfile FROM org
249 | run: sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:latest/" Dockerfile
250 | - name: Login to DockerHub
251 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
252 | with:
253 | username: ${{ secrets.DOCKER_USER }}
254 | password: ${{ secrets.DOCKER_TOKEN }}
255 | - name: Login to GitHub Container Registry
256 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
257 | with:
258 | registry: ghcr.io
259 | username: ${{ github.actor }}
260 | password: ${{ secrets.GITHUB_TOKEN }}
261 | - name: Retry build and push
262 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
263 | with:
264 | timeout_minutes: 60
265 | max_attempts: 3
266 | command: |
267 | docker buildx build \
268 | --file Dockerfile \
269 | --platform linux/amd64,linux/arm64 \
270 | --tag ${{ env.ORG }}/github-runner:latest \
271 | --tag ghcr.io/${{ github.repository }}:latest \
272 | --push \
273 | --pull \
274 | --cache-from type=gha \
275 | --cache-to type=gha,mode=max \
276 | .
277 |
278 | ubuntu_deploy:
279 | runs-on: ubuntu-latest
280 | needs: ubuntu_tests
281 | strategy:
282 | matrix:
283 | release: [jammy, focal, noble]
284 | fail-fast: false
285 | steps:
286 | - name: Copy Repo Files
287 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
288 | - name: Get GitHub organization or user
289 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
290 | - name: Set up QEMU
291 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
292 | with:
293 | image: tonistiigi/binfmt:qemu-v7.0.0
294 | - name: Set up Docker Buildx
295 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
296 | - name: Copy Dockerfile
297 | run: cp Dockerfile Dockerfile.ubuntu-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:ubuntu-${{ matrix.release }}/" Dockerfile.ubuntu-${{ matrix.release }}
298 | - name: Login to DockerHub
299 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
300 | with:
301 | username: ${{ secrets.DOCKER_USER }}
302 | password: ${{ secrets.DOCKER_TOKEN }}
303 | - name: Login to GitHub Container Registry
304 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
305 | with:
306 | registry: ghcr.io
307 | username: ${{ github.actor }}
308 | password: ${{ secrets.GITHUB_TOKEN }}
309 | - name: Retry build and push
310 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
311 | with:
312 | timeout_minutes: 60
313 | max_attempts: 3
314 | command: |
315 | docker buildx build \
316 | --file Dockerfile.ubuntu-${{ matrix.release }} \
317 | --platform linux/amd64,linux/arm64 \
318 | --tag ${{ env.ORG }}/github-runner:ubuntu-${{ matrix.release }} \
319 | --tag ghcr.io/${{ github.repository }}:ubuntu-${{ matrix.release }} \
320 | --push \
321 | --pull \
322 | --cache-from type=gha \
323 | --cache-to type=gha,mode=max \
324 | .
325 |
326 | debian_deploy:
327 | runs-on: ubuntu-latest
328 | needs: debian_tests
329 | strategy:
330 | matrix:
331 | release: [bookworm, trixie]
332 | fail-fast: false
333 | steps:
334 | - name: Copy Repo Files
335 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
336 | - name: Get GitHub organization or user
337 | run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
338 | - name: Set up QEMU
339 | uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
340 | with:
341 | image: tonistiigi/binfmt:qemu-v7.0.0
342 | - name: Set up Docker Buildx
343 | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
344 | - name: Copy Dockerfile
345 | run: cp Dockerfile Dockerfile.debian-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:debian-${{ matrix.release }}/" Dockerfile.debian-${{ matrix.release }}
346 | - name: Login to DockerHub
347 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
348 | with:
349 | username: ${{ secrets.DOCKER_USER }}
350 | password: ${{ secrets.DOCKER_TOKEN }}
351 | - name: Login to GitHub Container Registry
352 | uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
353 | with:
354 | registry: ghcr.io
355 | username: ${{ github.actor }}
356 | password: ${{ secrets.GITHUB_TOKEN }}
357 | - name: Retry build and push
358 | uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
359 | with:
360 | timeout_minutes: 60
361 | max_attempts: 3
362 | command: |
363 | docker buildx build \
364 | --file Dockerfile.debian-${{ matrix.release }} \
365 | --platform linux/amd64,linux/arm64 \
366 | --tag ${{ env.ORG }}/github-runner:debian-${{ matrix.release }} \
367 | --tag ghcr.io/${{ github.repository }}:debian-${{ matrix.release }} \
368 | --push \
369 | --pull \
370 | --cache-from type=gha \
371 | --cache-to type=gha,mode=max \
372 | .
373 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------