2024-03-30 08:16:52 +00:00
|
|
|
name: Docker - Server
|
|
|
|
on:
|
2024-03-31 08:25:32 +00:00
|
|
|
release:
|
|
|
|
types: [created]
|
2024-03-30 08:16:52 +00:00
|
|
|
workflow_dispatch:
|
2024-03-31 08:25:32 +00:00
|
|
|
inputs:
|
|
|
|
tag:
|
|
|
|
description: 'Tag to use (leave empty for latest)'
|
|
|
|
required: false
|
|
|
|
default: ''
|
2024-03-30 08:16:52 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}-server
|
|
|
|
|
|
|
|
jobs:
|
2024-03-31 08:25:32 +00:00
|
|
|
build:
|
2024-03-30 08:16:52 +00:00
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v3
|
2024-03-31 08:25:32 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Grub Tag
|
|
|
|
run: |
|
|
|
|
if [[ "${{ github.event_name }}" == "release" ]]; then
|
|
|
|
echo "Using release tag ${{ github.event.release.tag_name }}"
|
|
|
|
echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
|
|
|
elif [[ -z "${{ github.event.inputs.tag }}" ]]; then
|
|
|
|
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
|
|
|
|
echo "Using latest tag $LATEST_TAG"
|
|
|
|
echo "TAG=$LATEST_TAG" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "Using manually specified tag ${{ github.event.inputs.tag }}"
|
|
|
|
echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
|
|
|
|
fi
|
2024-03-30 08:16:52 +00:00
|
|
|
- name: Log into registry ${{ env.REGISTRY }}
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract Docker metadata
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
2024-03-31 08:25:32 +00:00
|
|
|
tags: type=raw,value=${{ env.TAG }}
|
2024-03-30 08:16:52 +00:00
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
- name: Build and push Docker image
|
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
|
|
|
platforms: linux/amd64
|
|
|
|
context: .
|
|
|
|
file: docker/Dockerfile
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|