CI/CD: Use built-in GITHUB_TOKEN for automatic authentication
Build and Push Docker Image / build (push) Failing after 31s
Build and Push Docker Image / build (push) Failing after 31s
This commit is contained in:
@@ -12,15 +12,15 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Log in to Gitea Registry
|
- name: Log in to Gitea Registry
|
||||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login git.pengzhan.dev -u "${{ github.actor }}" --password-stdin
|
# 使用系统自动注入的 GITHUB_TOKEN,无需手动配置
|
||||||
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login git.pengzhan.dev -u "${{ github.actor }}" --password-stdin
|
||||||
|
|
||||||
# 有些 Gitea 环境下,docker build 可能需要 sudo,或者特定的权限
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
run: |
|
run: |
|
||||||
IMAGE_NAME="git.pengzhan.dev/${{ github.repository }}"
|
# 提取仓库名并转为小写
|
||||||
# 转换为小写,防止因为仓库名包含大写导致镜像推送失败
|
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||||
IMAGE_NAME_LC=$(echo "$IMAGE_NAME" | tr '[:upper:]' '[:lower:]')
|
IMAGE_NAME="git.pengzhan.dev/$REPO_NAME"
|
||||||
|
|
||||||
docker build -t $IMAGE_NAME_LC:latest -t $IMAGE_NAME_LC:${{ github.sha }} .
|
docker build -t $IMAGE_NAME:latest -t $IMAGE_NAME:${{ github.sha }} .
|
||||||
docker push $IMAGE_NAME_LC:latest
|
docker push $IMAGE_NAME:latest
|
||||||
docker push $IMAGE_NAME_LC:${{ github.sha }}
|
docker push $IMAGE_NAME:${{ github.sha }}
|
||||||
|
|||||||
Reference in New Issue
Block a user