Configure CI workflow to run only on GitHub and improve Docker tagging strategy
- Add github.server_url check to prevent workflow execution on Gitea - Implement clear separation between development (latest) and production (stable) tags - Use stable tag only for versioned releases (v*) - Add sha- prefix to commit-based tags for better clarity - Remove redundant branch name tags
This commit is contained in:
@@ -11,6 +11,7 @@ jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
if: github.server_url == 'https://github.com'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -34,6 +35,7 @@ jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
if: github.server_url == 'https://github.com'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -57,7 +59,7 @@ jobs:
|
||||
name: Build and Push Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test, lint]
|
||||
if: github.event_name == 'push'
|
||||
if: github.event_name == 'push' && github.server_url == 'https://github.com'
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
@@ -78,10 +80,10 @@ jobs:
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=sha
|
||||
type=sha,prefix=sha-
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
|
||||
Reference in New Issue
Block a user