【发布时间】:2021-09-01 13:31:39
【问题描述】:
我目前正在尝试运行一个 docker GitHub Action,它构建一个 docker 图像并将其推送到 GitHub 包,但我收到了一个我从未见过的错误。由于某种原因,它无法推送 docker 映像,因为 write_permission 被拒绝,但我有一个令牌允许我写,所以我不明白问题是什么。
这是我的动作文件:
name: Docker Image CI
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 16
uses: actions/setup-java@v1
with:
java-version: 16
- name: Build with Maven
run: mvn -f ACS/pom.xml clean install dependency:copy-dependencies
- name: Login to GitHub Package Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.repository }} --password-stdin
- name: Build the Docker image
run: docker build -t image:latest .
- name: Tag the Docker image
run: docker tag image:latest docker.pkg.github.com/organization/repository/image:latest
- name: Push the Docker image to the registry
run: docker push docker.pkg.github.com/organization/repository/image:latest
这是我的错误:
运行 docker push docker.pkg.github.com/organization/repository/image:latest 推送是指存储库 [docker.pkg.github.com/organization/repository/image] f0eaf014e806:准备 7d0bad636b3f:准备 aa0870e7c621: 准备 36d2f9f005e6:准备 22bb3686ee25:准备 05e198868a20:准备 b5cea4a3dd43:准备 93c7a8a0e1f4: 准备 7f4b55b885b0:准备 05e198868a20:等待 b5cea4a3dd43: 等待 93c7a8a0e1f4:等待 7f4b55b885b0:等待被拒绝: permission_denied: write_package
【问题讨论】:
-
参见stackoverflow.com/a/71193319/180258 - 如果第一个图像是使用 PAT 在本地推送,还是使用 GITHUB_TOKEN 从工作流推送,这会有所不同。
标签: docker github github-actions