docker #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: docker | |
on: | |
workflow_dispatch: | |
inputs: | |
dockerfile: | |
description: 'Select the Dockerfile to use' | |
required: true | |
default: 'Dockerfile.dachub_auth' | |
options: | |
- Dockerfile.dachub_auth | |
- Dockerfile.incore_auth | |
jobs: | |
docker: | |
permissions: | |
contents: read | |
packages: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Extract name from Dockerfile input | |
- name: Extract Dockerfile name | |
id: extract_name | |
run: | | |
NAME=$(echo "${{ github.event.inputs.dockerfile }}" | cut -d'.' -f2) | |
echo "IMAGE_NAME=$NAME" >> $GITHUB_ENV | |
# Create metadata for image | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
hub.ncsa.illinois.edu/dachub/${{ env.IMAGE_NAME }} | |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Inspect Builder | |
run: | | |
echo "Name: ${{ steps.buildx.outputs.name }}" | |
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" | |
echo "Status: ${{ steps.buildx.outputs.status }}" | |
echo "Flags: ${{ steps.buildx.outputs.flags }}" | |
echo "Platforms: ${{ steps.buildx.outputs.platforms }}" | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to NCSA Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: hub.ncsa.illinois.edu | |
username: ${{ secrets.NCSA_HUB_USERNAME }} | |
password: ${{ secrets.NCSA_HUB_PASSWORD }} | |
# Build and push | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ${{ github.event.inputs.dockerfile }} | |
push: true | |
platforms: linux/amd64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
VERSION=${{ steps.meta.outputs.version }} |