Server Docker Image Github CI Fix (#333)

ci: fix job name error
ci: add tag option for manual deployment
This commit is contained in:
Trance233 2024-03-31 16:25:32 +08:00 committed by GitHub
parent 31891631d7
commit 55703521e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 6 deletions

View File

@ -1,16 +1,20 @@
name: Docker - Server
on:
push:
tags:
- "v*"
release:
types: [created]
workflow_dispatch:
inputs:
tag:
description: 'Tag to use (leave empty for latest)'
required: false
default: ''
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-server
jobs:
nightly:
build:
runs-on: ubuntu-22.04
permissions:
contents: read
@ -18,6 +22,21 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
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
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
@ -29,8 +48,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
tags: |
type=semver,pattern={{version}}
tags: type=raw,value=${{ env.TAG }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v3