2024-06-05 10:47:12 +00:00
|
|
|
name: build-image
|
2024-06-05 10:50:12 +00:00
|
|
|
on: [push]
|
2024-06-05 03:19:34 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-06-05 10:47:12 +00:00
|
|
|
build-image:
|
|
|
|
name: build-image
|
2024-06-05 03:19:34 +00:00
|
|
|
runs-on: dind-rootless
|
2024-06-05 10:47:12 +00:00
|
|
|
|
|
|
|
container:
|
|
|
|
image: ghcr.io/catthehacker/ubuntu:act-latest
|
|
|
|
# image: gitea/runner-images:ubuntu-latest
|
2024-06-05 10:52:33 +00:00
|
|
|
# image: gitea.example.com/xyz/ubuntu-act:22.04
|
2024-06-05 10:47:12 +00:00
|
|
|
# credentials:
|
|
|
|
# username: ${{ gitea.actor }}
|
|
|
|
# password: ${{ secrets.GA_TOKEN }}
|
|
|
|
|
2024-06-05 03:19:34 +00:00
|
|
|
steps:
|
2024-06-05 10:47:12 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install QEMU
|
2024-06-05 03:19:34 +00:00
|
|
|
run: |
|
2024-06-05 10:47:12 +00:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y qemu-user-static
|
|
|
|
#
|
|
|
|
# https://github.com/docker/metadata-action
|
|
|
|
#
|
|
|
|
# - name: Docker meta
|
|
|
|
# id: meta
|
|
|
|
# uses: docker/metadata-action@v5
|
|
|
|
# with:
|
|
|
|
# images: |
|
|
|
|
# gitea.example.com/xyz/alpine
|
|
|
|
# tags: |
|
|
|
|
# type=schedule,pattern={{date 'YYYYMMDDHHMM'}}
|
|
|
|
# type=semver,pattern={{version}}
|
|
|
|
# type=semver,pattern={{major}}.{{minor}}
|
|
|
|
# type=semver,pattern={{major}}
|
|
|
|
# type=sha
|
|
|
|
- name: Set up Docker Context for Buildx
|
|
|
|
id: buildx-context
|
2024-06-05 03:19:34 +00:00
|
|
|
run: |
|
2024-06-05 10:47:12 +00:00
|
|
|
export DOCKER_HOST=tcp://docker:2376/
|
|
|
|
export DOCKER_TLS_CERTDIR="/certs"
|
|
|
|
export DOCKER_TLS_VERIFY=1
|
|
|
|
export DOCKER_CERT_PATH="/certs/client"
|
|
|
|
docker context create builders
|
|
|
|
# https://github.com/docker/setup-buildx-action
|
|
|
|
# https://docs.docker.com/engine/reference/commandline/cli/#environment-variables
|
|
|
|
- name: Setup Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
with:
|
|
|
|
# buildkitd-flags: --debug
|
|
|
|
endpoint: builders
|
2024-06-05 03:19:34 +00:00
|
|
|
env:
|
2024-06-05 10:47:12 +00:00
|
|
|
DOCKER_HOST: "tcp://docker:2376/"
|
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
|
|
|
DOCKER_TLS_VERIFY: 1
|
|
|
|
DOCKER_CERT_PATH: "/certs/client"
|
2024-06-05 03:19:34 +00:00
|
|
|
|
2024-06-05 10:47:12 +00:00
|
|
|
#
|
|
|
|
# Debug
|
|
|
|
#
|
|
|
|
- name: Available platforms
|
|
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
|
|
|
|
|
|
|
#
|
|
|
|
# https://github.com/docker/login-action
|
|
|
|
#
|
|
|
|
- name: Login to Gitea
|
|
|
|
uses: docker/login-action@v3
|
2024-06-05 03:19:34 +00:00
|
|
|
with:
|
|
|
|
registry: code.spamasaurus.com
|
2024-06-05 10:47:12 +00:00
|
|
|
username: ${{ gitea.actor }}
|
2024-06-05 03:19:34 +00:00
|
|
|
password: ${{ secrets.GIT_APIKEY }}
|
|
|
|
|
2024-06-05 10:47:12 +00:00
|
|
|
#
|
|
|
|
# https://github.com/docker/build-push-action
|
|
|
|
#
|
|
|
|
- name: Build and push the image
|
|
|
|
if: gitea.event_name != 'pull_request'
|
|
|
|
uses: docker/build-push-action@v5
|
2024-06-05 03:19:34 +00:00
|
|
|
with:
|
2024-06-05 10:47:12 +00:00
|
|
|
push: ${{ gitea.event_name != 'pull_request' }}
|
|
|
|
platforms: linux/amd64
|
|
|
|
context: containers/test
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
env:
|
|
|
|
DOCKER_HOST: "tcp://docker:2376/"
|
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
|
|
|
DOCKER_TLS_VERIFY: 1
|
|
|
|
DOCKER_CERT_PATH: "/certs/client"
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
- name: Inspect
|
2024-06-05 03:19:34 +00:00
|
|
|
run: |
|
2024-06-05 10:47:12 +00:00
|
|
|
docker buildx imagetools inspect gitea.example.com/xyz/ubuntu-act:22.04
|
2024-06-05 03:19:34 +00:00
|
|
|
env:
|
2024-06-05 10:47:12 +00:00
|
|
|
DOCKER_HOST: "tcp://docker:2376/"
|
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
|
|
|
DOCKER_TLS_VERIFY: 1
|
|
|
|
DOCKER_CERT_PATH: "/certs/client"
|