Skip to content

add build-push action #1

add build-push action

add build-push action #1

# Build and push images to:
# GitHub Container Registry (ghcr.io)
name: "Build Docker Images"
on:
workflow_dispatch: null
push:
branches:
- "*"
paths:
- "Dockerfile.*"
- "backup_restore/*"
- ".github/workflows/build-push-docker.yaml"
env:
DOCKER_ORG: nebari
BASE_IMAGE: ubuntu:20.04
permissions:
contents: read
packages: write
id-token: write
security-events: write
# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-images:
name: "Build Docker Images"
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository 🛎️"
uses: actions/checkout@v3
- name: "Set up Docker Buildx 🛠️"
uses: docker/setup-buildx-action@v2
- name: "Login to GitHub Container Registry 🔐"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.BOT_GHCR_TOKEN }}
# - name: "Login to Quay Container Registry 🔐"
# uses: docker/login-action@v2
# with:
# registry: quay.io
# username: ${{ secrets.QUAY_USERNAME }}
# password: ${{ secrets.QUAY_TOKEN }}
- name: "Generate Docker images tags 🏷️"
id: meta
uses: docker/metadata-action@v4
with:
images: |
"ghcr.io/${{ github.repository_owner }}/nebari-backup-restore${{ env.IMAGE_SUFFIX }}"
tags: |
# branch event -> e.g. `main-f0f6994-20221001`
type=ref, event=branch, suffix=-{{sha}}-{{date 'YYYYMMDD'}}
# needed for integration tests
type=ref, event=branch
# on tag push -> e.g. `2022.10.1`
type=ref, event=tag
- name: "Inspect image dir tree 🔍"
run: |
sudo apt-get install tree
tree .
- name: "Build docker images 🐳"
uses: docker/build-push-action@v3
with:
context: .
file: "Dockerfile"
tags: ${{ steps.meta.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: BASE_IMAGE=${{ env.BASE_IMAGE }}
platforms: linux/amd64,linux/arm64