3proxy/.github/workflows/docker-ghcr.yml
Vladimir Dubrovin 34e9c453fa Workflows update
2026-05-31 13:47:41 +03:00

94 lines
2.9 KiB
YAML

name: Build Docker images (GHCR)
on:
push:
branches: [master]
paths:
- 'RELEASE'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: Build and push Docker images
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Determine tags
id: tags
env:
REF: ${{ github.ref }}
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: |
if [[ "$REF" == refs/tags/* ]]; then
RELEASE=$(cat RELEASE)
echo "minimal=${IMAGE}:${RELEASE}.minimal,${IMAGE}:minimal" >> "$GITHUB_OUTPUT"
echo "busybox=${IMAGE}:${RELEASE}.busybox,${IMAGE}:busybox" >> "$GITHUB_OUTPUT"
echo "full=${IMAGE}:${RELEASE},${IMAGE}:latest" >> "$GITHUB_OUTPUT"
else
DATETIME=$(date +%d%m%y%H%M%S)
echo "minimal=${IMAGE}:${DATETIME}-devel.minimal,${IMAGE}:devel.minimal" >> "$GITHUB_OUTPUT"
echo "busybox=${IMAGE}:${DATETIME}-devel.busybox,${IMAGE}:devel.busybox" >> "$GITHUB_OUTPUT"
echo "full=${IMAGE}:${DATETIME}-devel,${IMAGE}:devel" >> "$GITHUB_OUTPUT"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push minimal
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.minimal
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
no-cache: true
tags: ${{ steps.tags.outputs.minimal }}
- name: Build and push busybox
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.busybox
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
no-cache: true
tags: ${{ steps.tags.outputs.busybox }}
- name: Build and push full
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.full
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
no-cache: true
tags: ${{ steps.tags.outputs.full }}
- name: Delete untagged GHCR images
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 3proxy
package-type: container
delete-only-untagged-versions: true