Files
landing/.gitea/workflows/build.yml
T
nick f90e118493
build / build-and-push (push) Successful in 12s
Fix docker login credential helper issue in CI
2026-07-12 06:23:20 +08:00

32 lines
1.3 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: build
on:
push:
branches: [main]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to Gitea container registry
# job 容器繼承了 hostOrbStack)的 ~/.docker/config.json
# 裡面設定 credsStore: osxkeychain,但容器是 Linux 環境,
# 沒有 macOS 專屬的 docker-credential-osxkeychain 可執行
# 檔,docker login 會找不到它而失敗。移除這個 credsStore
# 設定,讓 docker login 改用純文字存憑證(寫進 job 容器
# 內的 ~/.docker/config.json,容器本身就是一次性的,跑完
# job 就銷毀,不像本機長期環境需要 Keychain 加密)。
run: |
mkdir -p ~/.docker
echo '{}' > ~/.docker/config.json
echo "${{ secrets.CI_REGISTRY_TOKEN }}" | docker login gitea.niq-dev.com -u "${{ gitea.actor }}" --password-stdin
- name: Build image
run: docker build -t gitea.niq-dev.com/gitea_admin/landing:${{ gitea.sha }} -t gitea.niq-dev.com/gitea_admin/landing:latest .
- name: Push image
run: |
docker push gitea.niq-dev.com/gitea_admin/landing:${{ gitea.sha }}
docker push gitea.niq-dev.com/gitea_admin/landing:latest