Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Update index.md

Update index.md #102

name: Create and publish a Docker image
on:
push:
branches: ["**"] # run for any commit or tag push on any branch
tags-ignore: ["v**"] # reserve v* tags for releases
jobs:
build-and-push-image:
name: Build and publish docker images
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile
image: ghcr.io/${{ github.repository }}-application
context: .
- dockerfile: tutorial/Dockerfile
image: ghcr.io/${{ github.repository }}-tutorial
context: tutorial
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Build and Push Digest
id: build
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true