GitHub Action to push a container image to an image registry.
Find a file
divyansh42 ae3d342a76 Add changelog for v2.1.1
Signed-off-by: divyansh42 <diagrawa@redhat.com>
2021-02-26 00:52:55 +05:30
.github/workflows Simplify 'echo outputs' workflow steps 2021-02-22 11:49:46 +05:30
dist Improve error message when images not found (#31) 2021-02-25 12:01:09 -05:00
git-hooks Print image digest after every push 2021-02-20 14:07:32 -05:00
src Improve error message when images not found (#31) 2021-02-25 12:01:09 -05:00
.eslintrc.js Solve issue when image is present in Podman and Docker both (#16) 2021-01-19 10:24:49 -05:00
.gitignore first implementation push to quay action 2020-11-07 13:04:04 +01:00
action.yml Add back singular registry-path output 2021-02-22 11:49:46 +05:30
CHANGELOG.md Add changelog for v2.1.1 2021-02-26 00:52:55 +05:30
LICENSE first implementation push to quay action 2020-11-07 13:04:04 +01:00
package-lock.json Add IO generator and CI checks (#21) 2021-02-08 13:30:15 -05:00
package.json Add IO generator and CI checks (#21) 2021-02-08 13:30:15 -05:00
README.md Add note about ubuntu/Podman version 2021-02-22 14:10:22 -05:00
tsconfig.json Solve issue when image is present in Podman and Docker both (#16) 2021-01-19 10:24:49 -05:00

push-to-registry

CI checks Test Build and Push Multiple container CLI build tests Link checker

tag badge license badge size badge

Push-to-registry is a GitHub Action for pushing a container image to an image registry, such as Dockerhub, Quay.io, the GitHub Container Registry, or an OpenShift integrated registry.

This action only runs on Linux, as it uses podman to perform the push. GitHub's Ubuntu action runners come with Podman preinstalled. If you are not using those runners, you must first install Podman.

Action Inputs

Refer to the podman push documentation for more information.

Input Required Description
image Yes Name of the image you want to push.
tags No The tag or tags of the image to push. For multiple tags, seperate by a space. For example, latest ${{ github.sha }}
Defaults to latest.
registry Yes URL of the registry to push the image to.
Eg. quay.io/<username>
username Yes Username with which to authenticate to the registry.
password Yes Password, encrypted password, or access token with which to authenticate to the registry.
tls-verify No Verify TLS certificates when contacting the registry. Set to "false" to skip certificate verification.
digestfile No After copying the image, write the digest of the resulting image to the file. By default, the filename will be determined from the image and tag. The contents of this file are the digest output.
extra-args No Extra args to be passed to podman push. Separate arguments by newline. Do not use quotes.

Action Outputs

digest: The pushed image digest, as written to the digestfile.
For example, sha256:66ce924069ec4181725d15aa27f34afbaf082f434f448dc07a42daa3305cdab3. For multiple tags, the digest is the same.

registry-paths: A JSON array of registry paths to which the tag(s) were pushed.
For example, [ quay.io/username/spring-image:v1, quay.io/username/spring-image:latest ].

registry-path: The first element of registry-paths, as a string.

Examples

The example below shows how the push-to-registry action can be used to push an image created by the buildah-build action.

name: Build and Push Image
on: [ push ]

jobs:
  build:
    name: Build and push image
    runs-on: ubuntu-20.04
    env:
      IMAGE_NAME: my-app
      IMAGE_TAGS: latest v1

    steps:
    - uses: actions/checkout@v2

    - name: Build Image
      id: build-image
      uses: redhat-actions/buildah-build@v2
      with:
        image: ${{ env.IMAGE_NAME }}
        tags: ${{ env.IMAGE_TAGS }}
        base-image: some_image
        dockerfiles: |
          ./Dockerfile

    - name: Push To Quay
      id: push-to-quay
      uses: redhat-actions/push-to-registry@v2
      with:
        image: ${{ steps.build-image.outputs.image }}
        tags: ${{ steps.build-image.outputs.tags }}
        registry: ${{ secrets.QUAY_REPO }}
        username: ${{ secrets.QUAY_USERNAME }}
        password: ${{ secrets.QUAY_TOKEN }}

    - name: Use the image
      run: echo "New image has been pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

Note about images built with Docker

This action uses Podman to push, but can also push images built with Docker. However, Docker and Podman store their images in different locations, and Podman can only push images in its own storage.

If the image to push is present in the Docker image storage but not in the Podman image storage, it will be pulled into Podman's storage.

If the image to push is present in both the Docker and Podman image storage, the action will push the image which was more recently built, and log a warning.

If the action pulled an image from the Docker image storage into the Podman storage, it will be cleaned up from the Podman storage before the action exits.

Note about GitHub runners and Podman

We recommend using runs-on: ubuntu-20.04 since it has a newer version of Podman.

If you are on ubuntu-18.04 (which is currently aliased to ubuntu-latest) your workflow will use an older version of Podman and may encounter issues such as #26.

Troubleshooting

Note that quay.io repositories are private by default.

This means that if you push an image for the first time, you will have to authenticate before pulling it, or go to the repository's settings and change its visibility.