This commit is contained in:
64
.gitea/workflows/build-image.yml
Normal file
64
.gitea/workflows/build-image.yml
Normal file
@@ -0,0 +1,64 @@
|
||||
name: Build and Push Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set image variables
|
||||
id: vars
|
||||
env:
|
||||
REGISTRY_URL: ${{ secrets.REGISTRY_URL }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
REGISTRY_HOST="${REGISTRY_URL#https://}"
|
||||
REGISTRY_HOST="${REGISTRY_HOST#http://}"
|
||||
REPO_NAME="${GITHUB_REPOSITORY##*/}"
|
||||
if [ -z "$REPO_NAME" ]; then
|
||||
REPO_NAME="$(basename "$PWD")"
|
||||
fi
|
||||
TERRARIA_VERSION="$(awk -F= '/^ARG T_VERSION=/{print $2; exit}' Dockerfile)"
|
||||
if [ -z "$TERRARIA_VERSION" ]; then
|
||||
echo "T_VERSION not found in Dockerfile" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "registry_host=$REGISTRY_HOST" >> "$GITHUB_OUTPUT"
|
||||
echo "image=$REGISTRY_HOST/$REPO_NAME" >> "$GITHUB_OUTPUT"
|
||||
echo "terraria_version=$TERRARIA_VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ steps.vars.outputs.registry_host }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ steps.vars.outputs.image }}
|
||||
tags: |
|
||||
type=sha
|
||||
type=raw,value=latest
|
||||
type=raw,value=${{ steps.vars.outputs.terraria_version }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
Reference in New Issue
Block a user