Giter VIP home page Giter VIP logo

build-and-push-action's Introduction

The Build and Push GitHub Action

The action builds a container image and pushes it to the specified registry. The path to upload the image is constructed from inputs as follows:

registry/registry_namespace/image_name

Action Inputs

Registry information

Input Name Description Default value
registry Registry to push container image to. required
registry_namespace Namespace of the registry, where the image would be pushed. required
registry_username Login to specified registry. required
registry_token Access token to specified registry. required

Build information

Input Name Description Default value
image_name Name of the built image. required
tag Tag of the built image. ""
use_default_tags Add default tags to image - SHA, latest, current date true
archs Label the image with this architecture. For multiple architectures, seperate them by a comma. amd64
dockerfile Dockerfile and its relative path to build the image. Dockerfile
docker_context Docker build context. .

Other information

Input Name Description Default value
readme If path to readme is set, the readme is updated to the registry. Only quay.io is supported. ""
quay_application_token Application token is used for updating description for image. ""

Example

The example below shows how the sclorg/build-and-push-action can be used.

name: Build and push to quay.io registry
on:
  push:
    branches:
      - main

jobs:
  build-and-push:
    runs-on: ubuntu-20.04
    steps:
      - name: Build and push to quay.io registry
        uses: sclorg/build-and-push-action@v2
        with:
          registry: "quay.io"
          registry_namespace: "namespace"
          registry_username: ${{ secrets.REGISTRY_LOGIN }}
          registry_token: ${{ secrets.REGISTRY_TOKEN }}
          dockerfile: "1.20/Dockerfile"
          image_name: "container_image-1.20"
          tag: "tag"

Multi arch builds

Input archs is provided to build the multi architecture images. archs input should be comma separated ( i.e. archs: "amd64, s390x" ). It is an optional argument, if not provided image will be built on amd64 i.e. default arch

The example below shows how the sclorg/build-and-push-action can be used for multi-arch image

name: Build and push to quay.io registry
on:
  push:
    branches:
      - main

jobs:
  build-and-push:
    runs-on: ubuntu-20.04
    steps:
      - name: Build and push to quay.io registry
        uses: sclorg/build-and-push-action@v2
        with:
          registry: "quay.io"
          registry_namespace: "namespace"
          registry_username: ${{ secrets.REGISTRY_LOGIN }}
          registry_token: ${{ secrets.REGISTRY_TOKEN }}
          dockerfile: "1.20/Dockerfile"
          image_name: "container_image-1.20"
          tag: "tag"
          archs: "amd64, s390x"

build-and-push-action's People

Contributors

dependabot[bot] avatar modassarrana89 avatar phracek avatar zmiklank avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

build-and-push-action's Issues

Add flag with commit hash to built images

Currently, we pass github.sha to buildah, to create image with this tag.
However, we use also "latest" tag and tag with current date.

That means, that if user pulls the image via other then sha tag, it will no longer be possible to get the commit hash from the image.

We should consider adding some information about hash of the latest commit to the released images.

What is the resulting image name: opportunity to improve transparency

It took me a while and a look into the code to realize what the resulting image actually is, because it's composed from more parts, each part coming from a different source:

        image: ${{ steps.base-image-name.outputs.image_name}}-${{ steps.clean_path.outputs.clean_dockerfile_path }}${{ steps.suffix_name.outputs.suffix }}

I think that improving transparency on the expense of more duplication here might be not that bad idea, which means the specification would simply include the resulting name. One of the possible implementation might be adding something like "output_image" key, which might make some of the other keys not needed (didn't check), e.g.:

         - dockerfile_path: "18"
           dockerfile: "Dockerfile.fedora"
           registry_namespace: "fedora"
           tag: "fedora"
           output_image: "quay.io/fedora/nodejs-18"
           quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME"
           quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.