mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 00:20:44 +00:00
83 lines
2.8 KiB
YAML
83 lines
2.8 KiB
YAML
# Publish a container
|
|
name: 🐋 Container | Publish
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
project:
|
|
required: true
|
|
description: 'The container to publish'
|
|
type: string
|
|
version:
|
|
required: true
|
|
description: 'The version to release'
|
|
type: string
|
|
push:
|
|
tags:
|
|
- 'containers/*/v*.*.*'
|
|
|
|
jobs:
|
|
# This job either uses the inputs from the workflow_dispatch event,
|
|
# or will split values out of the pushed tag.
|
|
# This allows the release manager to either create a release themselves and have this job pick it up,
|
|
# Or run this job to create a release.
|
|
determine_values:
|
|
name: 🔎 Determine Values
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
category: ${{ steps.determine_values.outputs.category }}
|
|
version: ${{ steps.determine_values.outputs.version }}
|
|
project: ${{ steps.determine_values.outputs.project }}
|
|
|
|
steps:
|
|
- name: 🔎 Determine Project Values
|
|
id: determine_values
|
|
env:
|
|
CATEGORY_OVERRIDE: ${{ inputs.category }}
|
|
PROJECT_OVERRIDE: ${{ inputs.project }}
|
|
VERSION_OVERRIDE: ${{ inputs.version }}
|
|
TAG: ${{ github.ref_name }}
|
|
run: |
|
|
echo "category=${CATEGORY_OVERRIDE:-${TAG%%/*}}" >> $GITHUB_ENV
|
|
echo "version=${VERSION_OVERRIDE:-${TAG##*/}}" >> $GITHUB_ENV
|
|
dirname "project=${PROJECT_OVERRIDE:-${TAG#*/}}" >> $GITHUB_ENV
|
|
|
|
publish_container:
|
|
name: 🐋 Publish Container
|
|
needs: determine_values
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: 🚩 Checkout Repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 🔎 Introspect metadata
|
|
id: metadata
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
ghcr.io/civmc/civ/${{needs.determine_values.outputs.project}}
|
|
tags: |
|
|
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}},value=${{needs.determine_values.outputs.version}}
|
|
type=semver,pattern={{major}}.{{minor}},value=${{needs.determine_values.outputs.version}}
|
|
type=semver,pattern={{major}},value=${{needs.determine_values.outputs.version}}
|
|
|
|
- name: 🪵 Login to Github Packages
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: 🐳 Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: containers/${{needs.determine_values.outputs.project}}
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.metadata.outputs.tags }}
|
|
labels: ${{ steps.metadata.outputs.labels }}
|