Files
gitea-debian-runner/.github/workflows/build-ubuntu.yml
T
Ryan (hackercat) 6ffb01cfd3 Refactor again (#11)
2021-05-28 13:31:42 +02:00

185 lines
5.7 KiB
YAML

name: Build ubuntu images
on:
schedule:
- cron: 0 12 */7 * *
push:
paths:
- '.github/workflows/build-ubuntu.yml'
- 'linux/ubuntu/**'
branches:
- 'master'
pull_request:
paths:
- '.github/workflows/build-ubuntu.yml'
- 'linux/ubuntu/**'
workflow_dispatch:
env:
SLUG: ${{ github.repository_owner }}/ubuntu
IMAGE: ubuntu
PLATFORMS: linux/amd64,linux/arm64
NODE: '12'
jobs:
build:
runs-on: ubuntu-latest
environment: Images
strategy:
fail-fast: true
max-parallel: 4
matrix:
TAG: [latest, 20.04, 18.04, 16.04]
steps:
- name: Login to GitHub Container Registry
id: ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Quay
id: quay
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Login to Docker Hub
id: dckr
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Print tag
id: print-tag
shell: sh
run: |
if ${{ github.event_name == 'pull_request' }} && ${{ !env.ACT }} ; then
echo "::set-output name=tag::PR-${{ github.event.number }}"
elif ${{ !env.ACT }} ; then
echo "::set-output name=tag::$(date +%Y%m%d)"
else
echo "::set-output name=tag::dev"
fi
- name: Set Ubuntu version to RELEASE
id: print-release
run: |
if [ "latest" = "${{ matrix.TAG }}" ]; then
echo "::set-output name=RELEASE::$(lsb_release -rs)"
else
echo "::set-output name=RELEASE::${{ matrix.TAG }}"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- uses: actions/checkout@v2
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
TAG: act-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
with:
context: .
push: true
file: ./linux/${{ env.IMAGE }}/act/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
IMAGEOS=${{ env.IMAGE }}
NODE_VERSION=${{ env.NODE }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=act-${{ matrix.TAG }}
BUILD_REF=${{ github.sha }}
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
TAG: runner-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
with:
context: .
push: true
file: ./linux/${{ env.IMAGE }}/runner/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
IMAGE=ghcr.io/${{ env.SLUG }}
IMAGEOS=${{ env.IMAGE }}
TAG=act-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=runner
BUILD_REF=${{ github.sha }}
- uses: actions/setup-go@v1
with:
go-version: 1.16
- uses: actions/checkout@v2
with:
ref: cat/fix/change-image
repository: catthehacker/act-fork
path: act
- env:
ACT_TEST_IMAGE: ghcr.io/${{ env.SLUG }}:act-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
ACT_REPOSITORY: catthehacker/act-fork
ACT_OWNER: catthehacker
run: |
cd act/
go test ./...
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
TAG: act
with:
context: .
push: ${{ ( github.event_name != 'pull_request' && !env.ACT ) }}
file: ./linux/${{ env.IMAGE }}/act/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
NODE_VERSION=${{ env.NODE }}
IMAGEOS=${{ env.IMAGE }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=act-${{ matrix.TAG }}
BUILD_REF=${{ github.sha }}
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
TAG: runner
with:
context: .
push: ${{ ( github.event_name != 'pull_request' && !env.ACT ) }}
file: ./linux/${{ env.IMAGE }}/runner/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
IMAGE=ghcr.io/${{ env.SLUG }}
IMAGEOS=${{ env.IMAGE }}
TAG=act-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=runner-${{ matrix.TAG }}
BUILD_REF=${{ github.sha }}