66 lines
1.8 KiB
YAML
66 lines
1.8 KiB
YAML
name: Build and push Docker image
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
workflow_dispatch: {}
|
|
|
|
env:
|
|
REGISTRY: cr.nym.sh
|
|
# Default image path: cr.nym.sh/<owner>/tshock
|
|
IMAGE_NAME: cr.nym.sh/${{ github.repository_owner }}/tshock
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout
|
|
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
|
|
|
|
# Only log in (and push) when not a PR from a fork.
|
|
- name: Log in to registry
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
# When you push a git tag like v5.2.4 -> publish "5.2.4"
|
|
type=semver,pattern={{version}}
|
|
# latest for main branch
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
# short sha tag for traceability
|
|
type=sha,format=short
|
|
|
|
- name: Build (and push)
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
TSHOCK_VERSION=5.2.4
|
|
TERRARIA_VERSION=1.4.4.9 |