Skip to content

reinvented-stuff/build-docker-image-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build and push a Docker image GitHub action

Builds a Docker image and pushes it into a registry

Usage

Inputs

  • registry_address - Docker registry address
  • registry_username - Username to authorise in registry
  • registry_token - Token to authorise in registry
  • name - Name of the Docker image (incl. repository, excl. version)
  • build_args - Additional build arguments to pass to docker build command
  • working_directory - Where to look for Dockerfile
  • planned_version - Version to assign to the image
  • default_branch - Default branch name that would not be added to version tag part
  • skip_branch_suffix - Skip branch name in the tag even if the branch isn't the default one
  • fail_on_error - Fail the pipeline on error

Outputs

  • image_full_name - Full name of the pushed image

Example

---
name: Release

on:
  push:
    branches:
      - "*"

jobs:
  build_docker_image:
    name: Build Docker image
    runs-on: ubuntu-latest
    outputs:
      image_full_name: ${{ steps.build_docker_image.outputs.image_full_name }}

    steps:

      - name: Check out code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Build Docker image
        id: build_docker_image
        uses: reinvented-stuff/[email protected]
        with:
          registry_address: "ghcr.io"
          registry_username: "${{ github.actor }}"
          registry_token: "${{ secrets.GITHUB_TOKEN }}"
          name: "${{ github.repository }}/${{ env.APP_NAME }}"
          planned_version: "1.0.0"
          build_args: |
            NGINX_VERSION="1.6.12"

...