1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-04 23:40:26 +08:00
Files
WireGold/.github/workflows/docker.yml
2026-05-18 17:21:02 +08:00

110 lines
3.2 KiB
YAML

name: docker
on:
pull_request:
push:
branches:
- "**"
tags:
- "v*"
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
docker-ci:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build test image
uses: docker/build-push-action@v7
with:
context: .
load: true
tags: wiregold:test
build-args: |
VERSION=ci-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test help output
run: docker run --rm wiregold:test -h
- name: Smoke test key generation
run: docker run --rm wiregold:test -g
- name: Smoke test preshared key generation
run: docker run --rm wiregold:test -pg
- name: Smoke test missing TUN message
run: |
set -euo pipefail
output="$(docker run --rm wiregold:test 2>&1 || true)"
printf '%s\n' "$output"
printf '%s' "$output" | grep -F "WireGold requires /dev/net/tun inside the container."
docker-publish:
name: Publish GHCR image
runs-on: ubuntu-latest
needs: docker-ci
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch))
permissions:
contents: read
packages: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
labels: |
org.opencontainers.image.title=WireGold
org.opencontainers.image.description=Container image for WireGold, a pure-Go Layer 3 VPN inspired by WireGuard.
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v7
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max