91 lines
2.6 KiB
YAML
91 lines
2.6 KiB
YAML
name: Build and Publish Container
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch: {}
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
concurrency:
|
|
group: container-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
publish:
|
|
name: Publish Linux container
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Resolve registry image name
|
|
id: image
|
|
shell: bash
|
|
env:
|
|
SERVER_URL: ${{ github.server_url }}
|
|
REPOSITORY: ${{ github.repository }}
|
|
run: |
|
|
set -euo pipefail
|
|
registry="${SERVER_URL#http://}"
|
|
registry="${registry#https://}"
|
|
registry="${registry%%/*}"
|
|
repository="$(printf '%s' "$REPOSITORY" | tr '[:upper:]' '[:lower:]')"
|
|
echo "registry=$registry" >> "$GITHUB_OUTPUT"
|
|
echo "image=$registry/$repository" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Verify registry credentials
|
|
shell: bash
|
|
env:
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ -z "$REGISTRY_TOKEN" ]]; then
|
|
echo "::error::Add a REGISTRY_TOKEN repository secret containing a Gitea personal access token with write:package permission."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ steps.image.outputs.registry }}
|
|
username: ${{ secrets.REGISTRY_USERNAME || 'HRiggs' }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Generate image metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ steps.image.outputs.image }}
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,prefix=sha-
|
|
labels: |
|
|
org.opencontainers.image.title=Progression Mods
|
|
org.opencontainers.image.description=Progression RimWorld mod-list service
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and publish
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
provenance: false
|
|
|