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:
|
||||
push:
|
||||
branches: [ "**" ]
|
||||
branches: [ main, master ]
|
||||
tags: [ 'v*' ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [ main, master ]
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.25"
|
||||
REGISTRY: gitea.mrixs.me
|
||||
IMAGE_NAME: naviwatcher
|
||||
# Convert repository owner to lowercase for Docker compatibility
|
||||
REPO_OWNER_LOWER: ${{ toLower(gitea.repository_owner) }}
|
||||
# Using a fixed username since GITEA_REPOSITORY_OWNER may not be available
|
||||
# Replace 'Mrixs' with your actual Gitea username
|
||||
USERNAME: Mrixs
|
||||
|
||||
jobs:
|
||||
test:
|
||||
@@ -83,7 +84,7 @@ jobs:
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.repository_owner }}
|
||||
username: ${{ env.USERNAME }}
|
||||
password: ${{ secrets.PACKAGES_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
@@ -92,7 +93,7 @@ jobs:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.REPO_OWNER_LOWER }}/${{ env.IMAGE_NAME }}:latest
|
||||
${{ env.REGISTRY }}/${{ env.REPO_OWNER_LOWER }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER_LOWER }}/${{ env.IMAGE_NAME }}:buildcache
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER_LOWER }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
||||
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:latest
|
||||
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:buildcache
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
||||
Reference in New Issue
Block a user