Files
my-docs/.github/workflows/buidl_and_push_ghcr.yml
gitea_admin 49fd51d0ec
Some checks failed
Gitea Docker Image CI / build (push) Failing after 6s
更新 .github/workflows/buidl_and_push_ghcr.yml
2025-12-18 06:52:50 +00:00

53 lines
1.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Gitea Docker Image CI
run-name: Build and Push to Gitea Registry
on:
workflow_dispatch:
push:
branches:
- main
# 关键修正 1显式声明 Actions Token 的权限
# 这会让 Gitea 自动生成的 GITHUB_TOKEN 拥有上传 Package 的能力
permissions:
packages: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare Variables
id: prep
run: |
CLEAN_HOST=$(echo "${{ gitea.server_url }}" | sed 's~http[s]*://~~g')
LOWER_REPO=$(echo "${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')
echo "registry_host=$CLEAN_HOST" >> $GITHUB_OUTPUT
echo "image_repo=$LOWER_REPO" >> $GITHUB_OUTPUT
- name: Create Kaniko Credentials
run: |
mkdir -p $HOME/.docker
HOST="${{ steps.prep.outputs.registry_host }}"
# 关键修正 2回归标准 GITHUB_TOKEN + gitea.actor
# 配合上面的 permissions 配置,这是最不会出错的组合
echo "{\"auths\":{\"$HOST\":{\"username\":\"${{ gitea.actor }}\",\"password\":\"${{ secrets.GITHUB_TOKEN }}\"}}}" > $HOME/.docker/config.json
- name: Build and Push with Kaniko
uses: docker://gcr.io/kaniko-project/executor:debug
env:
DOCKER_CONFIG: /github/home/.docker
with:
args: >-
--context .
--dockerfile ./Dockerfile
--destination ${{ steps.prep.outputs.registry_host }}/${{ steps.prep.outputs.image_repo }}:latest
--destination ${{ steps.prep.outputs.registry_host }}/${{ steps.prep.outputs.image_repo }}:${{ gitea.sha }}
--force
--cache=true
--insecure
--skip-tls-verify