Skip to content

Feature/add atlantis project name #350

Feature/add atlantis project name

Feature/add atlantis project name #350

Workflow file for this run

name: Build and publish container image
on:
# run when tagging or pushing to master
push:
branches: [master]
tags: ["*"]
# run on PRs against master
pull_request:
branches: [master]
# manual trigger
workflow_dispatch:
inputs:
tag:
description: Build a container image for this git tag
required: true
env:
# GitHub Container Registry hostname
GHCR_HOSTNAME: ghcr.io
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout the latest SHA for this branch
uses: actions/checkout@v2
if: github.event_name != 'workflow_dispatch'
- name: Checkout the specified tag
uses: actions/checkout@v2
if: github.event_name == 'workflow_dispatch'
with:
ref: ${{ github.event.inputs.tag }}
- name: Get the latest Dockerfile if needed
if: github.event_name == 'workflow_dispatch'
run: |
if [[ ! -f Dockerfile ]]; then
git fetch --depth=1 origin master
git checkout origin/master -- Dockerfile
fi
- name: Build and cache first build stage
# update the first stage cache only when pushing to or tagging main
if: github.event_name == 'push'
uses: docker/build-push-action@v4
env:
# use BuildKit to speed up builds and improve caching
DOCKER_BUILDKIT: 1
with:
registry: ${{ env.GHCR_HOSTNAME }}
repository: ${{ github.repository }}
target: build
tags: build
build-args: BUILDKIT_INLINE_CACHE=1
cache-froms: ${{ env.GHCR_HOSTNAME }}/${{ github.repository }}:build
- name: Build the container image
uses: docker/build-push-action@v4
env:
# use BuildKit to speed up builds and improve caching
DOCKER_BUILDKIT: 1
with:
registry: ${{ env.GHCR_HOSTNAME }}
repository: ${{ github.repository }}
# auto create the tag if we're in a push/pull_request
tag_with_ref: ${{ github.event_name != 'workflow_dispatch' }}
# this will add the proper tag if we're in workflow_dispatch
tags: ${{ github.event.inputs.tag }}
build-args: BUILDKIT_INLINE_CACHE=1
cache-froms: >
${{ env.GHCR_HOSTNAME }}/${{ github.repository }}:build,
${{ env.GHCR_HOSTNAME }}/${{ github.repository }}:latest