docker 个操作的新位置

New location of docker actions

我用这个 docker:

- name: Build container image
  uses: actions/docker/cli@master
  with:
    ///// removed

- name: Docker Login
  uses: actions/docker/login@master
  env:
    ///// removed

但是github。com/actions/docker似乎已经不存在了。

我的构建出现 404:

Failed to download action 'https://api.github.com/repos/actions/docker/tarball/master'. Error Response status code does not indicate success: 404 (Not Found).

有人知道新地点吗?

actions/docker 操作现已弃用。在完全删除之前,存储库已使用以下消息存档。

This action is deprecated in favor of using the run script step in the new YAML language to run the docker cli.

所以推荐使用Docker的方法是使用run脚本命令。官方入门工作流程展示了一个构建图像的简单示例。 https://github.com/actions/starter-workflows/blob/master/ci/docker-image.yml

有关 Docker 图片发布的更完整示例,请参阅以下工作流程。

对于 public DockerHub 注册表:

name: my workflow
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Login to DockerHub Registry
        run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
      - name: Build the Docker image
        run: docker build -t myimage:latest .
      - name: Tag the Docker image
        run: docker tag myimage:latest myimage:1.0
      - name: Push the Docker image to the registry
        run: docker push myimage:1.0

对于私有注册表,例如新的 GitHub 包注册表,您还需要在登录时指定主机名并适当地标记图像:

name: my workflow
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - 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 myimage:latest .
      - name: Tag the Docker image
        run: docker tag myimage:latest docker.pkg.github.com/username/repository/myimage:1.0
      - name: Push the Docker image to the registry
        run: docker push docker.pkg.github.com/username/repository/myimage:1.0