Some checks failed
Build with Kaniko (Fixed) / build (push) Failing after 29s
41 lines
1.5 KiB
YAML
41 lines
1.5 KiB
YAML
name: Build with Kaniko (Fixed)
|
||
|
||
on:
|
||
push:
|
||
branches: [ main ]
|
||
workflow_dispatch:
|
||
|
||
permissions:
|
||
packages: write
|
||
contents: read
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout code
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Build and Push
|
||
# 使用这个特殊的 Action,它只是一个本地 Shell 脚本包装,不需要从 GitHub 下载复杂的依赖
|
||
# 或者我们直接用 docker:// 语法(如下所示),这是最原生的
|
||
uses: docker://gcr.io/kaniko-project/executor:v1.23.2-debug
|
||
env:
|
||
# 这里的技巧是:Kaniko 读取环境变量中的认证信息
|
||
# 我们不创建文件,直接把 Gitea Token 传进去(Kaniko 不直接支持 ENV 认证,所以要用 shell 这种 trick)
|
||
GIT_USERNAME: ${{ gitea.actor }}
|
||
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||
with:
|
||
entrypoint: /busybox/sh
|
||
args: >-
|
||
-c
|
||
"echo '{\"auths\":{\"${{ gitea.server_url }}\":{\"username\":\"${{ gitea.actor }}\",\"password\":\"${{ secrets.GITHUB_TOKEN }}\"}}}' > /kaniko/.docker/config.json
|
||
&&
|
||
/kaniko/executor
|
||
--context=.
|
||
--dockerfile=Dockerfile
|
||
--destination=${{ gitea.server_url }}/${{ gitea.actor }}/my-docs:latest
|
||
--destination=${{ gitea.server_url }}/${{ gitea.actor }}/my-docs:${{ github.sha }}
|
||
--insecure
|
||
--skip-tls-verify
|
||
--cache=true" |