173 lines
6.9 KiB
YAML
173 lines
6.9 KiB
YAML
name: GitHub Actions Runner in Docker - Release
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*'
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
jobs:
|
|
create-release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- name: Create Release
|
|
id: create_release
|
|
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
release_name: Release ${{ github.ref }}
|
|
draft: false
|
|
prerelease: false
|
|
|
|
ubuntu_latest_tag:
|
|
runs-on: ubuntu-latest
|
|
needs: create-release
|
|
steps:
|
|
- name: Copy Repo Files
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- name: get version
|
|
run: echo 'TAG='${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
|
|
- name: Get GitHub organization or user
|
|
run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
|
|
with:
|
|
image: tonistiigi/binfmt:qemu-v7.0.0
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
|
- name: Update Dockerfile FROM org
|
|
run: sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:latest/" Dockerfile
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
|
with:
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Retry build and push
|
|
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4
|
|
with:
|
|
timeout_minutes: 60
|
|
max_attempts: 3
|
|
command: |
|
|
docker buildx build \
|
|
--file Dockerfile \
|
|
--platform linux/amd64,linux/arm64 \
|
|
--tag ${{ env.ORG }}/github-runner:${{ env.TAG }} \
|
|
--tag ghcr.io/${{ github.repository }}:${{ env.TAG }} \
|
|
--push \
|
|
--pull \
|
|
--cache-from type=gha \
|
|
--cache-to type=gha,mode=max \
|
|
.
|
|
|
|
ubuntu_tag:
|
|
runs-on: ubuntu-latest
|
|
needs: create-release
|
|
strategy:
|
|
matrix:
|
|
release: [jammy, focal, noble]
|
|
fail-fast: false
|
|
steps:
|
|
- name: Copy Repo Files
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- name: get version
|
|
run: echo 'TAG='${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
|
|
- name: Get GitHub organization or user
|
|
run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
|
|
with:
|
|
image: tonistiigi/binfmt:qemu-v7.0.0
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
|
- name: Copy Dockerfile
|
|
run: cp Dockerfile Dockerfile.ubuntu-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:ubuntu-${{ matrix.release }}/" Dockerfile.ubuntu-${{ matrix.release }}
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
|
with:
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Retry build and push
|
|
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4
|
|
with:
|
|
timeout_minutes: 60
|
|
max_attempts: 3
|
|
command: |
|
|
docker buildx build \
|
|
--file Dockerfile.ubuntu-${{ matrix.release }} \
|
|
--platform linux/amd64,linux/arm64 \
|
|
--tag ${{ env.ORG }}/github-runner:${{ env.TAG }}-ubuntu-${{ matrix.release }} \
|
|
--tag ghcr.io/${{ github.repository }}:${{ env.TAG }}-ubuntu-${{ matrix.release }} \
|
|
--push \
|
|
--pull \
|
|
--cache-from type=gha \
|
|
--cache-to type=gha,mode=max \
|
|
.
|
|
debian_tag:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
release: [bookworm, trixie]
|
|
fail-fast: false
|
|
needs: create-release
|
|
steps:
|
|
- name: Copy Repo Files
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- name: get version
|
|
run: echo 'TAG='${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
|
|
- name: Get GitHub organization or user
|
|
run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
|
|
with:
|
|
image: tonistiigi/binfmt:qemu-v7.0.0
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
|
- name: Copy Dockerfile
|
|
run: cp Dockerfile Dockerfile.debian-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:debian-${{ matrix.release }}/" Dockerfile.debian-${{ matrix.release }}
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
|
with:
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Retry build and push
|
|
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4
|
|
with:
|
|
timeout_minutes: 60
|
|
max_attempts: 3
|
|
command: |
|
|
docker buildx build \
|
|
--file Dockerfile.debian-${{ matrix.release }} \
|
|
--platform linux/amd64,linux/arm64 \
|
|
--tag ${{ env.ORG }}/github-runner:${{ env.TAG }}-debian-${{ matrix.release }} \
|
|
--tag ghcr.io/${{ github.repository }}:${{ env.TAG }}-debian-${{ matrix.release }} \
|
|
--push \
|
|
--pull \
|
|
--cache-from type=gha \
|
|
--cache-to type=gha,mode=max \
|
|
.
|