Add OCI annotations that is what ghcr.io registry uses #3
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 build and publish | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*' | |
env: | |
GITHUB_OWNER: 'moodlehq' | |
REPOSITORY: 'wiki-rag' | |
jobs: | |
Build-and-Publish: | |
# Completely avoid forks and pull requests to try this job. | |
if: github.repository_owner == 'moodlehq' && contains(fromJson('["push"]'), github.event_name) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for tags (we need that for setuptools-scm to find the version) | |
- name: Calculate image tags and labels | |
id: calculatetags | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ env.GITHUB_OWNER }}/${{ env.REPOSITORY }} | |
tags: | | |
type=pep440,pattern={{version}} | |
type=pep440,pattern={{major}}.{{minor}} | |
type=raw,value=latest,enable={{is_default_branch}} | |
env: | |
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker 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: Build and publish to GitHub registry | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
provenance: false | |
tags: ${{ steps.calculatetags.outputs.tags }} | |
labels: ${{ steps.calculatetags.outputs.labels }} | |
annotations: ${{ steps.calculatetags.outputs.annotations }} |