我正在尝试使用遵循其文档的github操作将docker映像推送到公共docker存储库,但我无法使其工作:
name: CI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/docker/login@master
with: # Set the secret as an input
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWPORD: ${{ secrets.DOCKER_PASSWPORD }}
env: # Set the secret in the env
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWPORD: ${{ secrets.DOCKER_PASSWPORD }}
- name: Test
run: mvn clean verify -U
- name: build
run: ./mvnw compile jib:dockerBuild
- name: push
run: docker push odfsoft/guess-game:latest
我收到以下错误:
/usr/bin/docker run --name bb8146f4246c56a44203bb2667ccfbdcab81_f18969 --label 04bb81 --workdir /github/workspace --rm -e DOCKER_USERNAME -e DOCKER_PASSWPORD -e INPUT_DOCKER_USERNAME -e INPUT_DOCKER_PASSWPORD -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/spring-boot-guess-game/spring-boot-guess-game":"/github/workspace" 04bb81:46f4246c56a44203bb2667ccfbdcab81
Error: Cannot perform an interactive login from a non TTY device
这与我的动作或github动作的限制有关吗?
答案 0 :(得分:1)
https://github.com/marketplace/actions/docker-login
请尝试执行此操作,因为actions/docker/login@master
已被弃用。
答案 1 :(得分:1)
actions/docker
操作现已被弃用。如果您访问存储库,则会看到该存储库已存档并显示以下消息。
不建议使用此操作,而建议使用新的YAML语言中的运行脚本步骤来运行docker cli。
https://github.com/actions/docker
因此,建议登录Docker注册表的方法是使用run
脚本命令,如下所示。
对于公共DockerHub注册中心:
name: my workflow
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
对于私有注册表,例如新的GitHub Package Registry,您还需要指定主机名:
name: my workflow
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Login to GitHub Package Registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login docker.pkg.github.com -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
有关docker映像发布的完整工作流示例,另请参见this answer。
答案 2 :(得分:0)
我发现Git集线器操作:构建并推送Docker映像
https://github.com/marketplace/actions/build-and-push-docker-images
效果很好,我能够构建并将Docker映像推送到Docker Hub。
答案 3 :(得分:-2)
要登录dockerhub,可以使用actions/docker repo中提供的操作。
看起来像这样:
action "Docker Login" {
uses = "actions/docker/login@master"
secrets = ["DOCKER_USERNAME", "DOCKER_PASSWORD"]
}