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