fix: CI/CD workflow - fix Docker image tag format issue
The error showed invalid reference format due to double slashes in the image tag. Fixed by: 1. Using a fixed username (Mrixs) instead of relying on gitea.repository_owner 2. Ensuring proper single-slash format: REGISTRY/USERNAME/IMAGE_NAME
This commit is contained in:
@@ -2,17 +2,18 @@ name: CI/CD
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "**" ]
|
branches: [ main, master ]
|
||||||
tags: [ 'v*' ]
|
tags: [ 'v*' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ main, master ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: "1.25"
|
GO_VERSION: "1.25"
|
||||||
REGISTRY: gitea.mrixs.me
|
REGISTRY: gitea.mrixs.me
|
||||||
IMAGE_NAME: naviwatcher
|
IMAGE_NAME: naviwatcher
|
||||||
# Convert repository owner to lowercase for Docker compatibility
|
# Using a fixed username since GITEA_REPOSITORY_OWNER may not be available
|
||||||
REPO_OWNER_LOWER: ${{ toLower(gitea.repository_owner) }}
|
# Replace 'Mrixs' with your actual Gitea username
|
||||||
|
USERNAME: Mrixs
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -83,7 +84,7 @@ jobs:
|
|||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ gitea.repository_owner }}
|
username: ${{ env.USERNAME }}
|
||||||
password: ${{ secrets.PACKAGES_TOKEN }}
|
password: ${{ secrets.PACKAGES_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
@@ -92,7 +93,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.REGISTRY }}/${{ env.REPO_OWNER_LOWER }}/${{ env.IMAGE_NAME }}:latest
|
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:latest
|
||||||
${{ env.REGISTRY }}/${{ env.REPO_OWNER_LOWER }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER_LOWER }}/${{ env.IMAGE_NAME }}:buildcache
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:buildcache
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER_LOWER }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
||||||
Reference in New Issue
Block a user