Skip to content

chore(anki-sync-server): bump version to null #52

chore(anki-sync-server): bump version to null

chore(anki-sync-server): bump version to null #52

# SPDX-FileCopyrightText: 2023 Frederik Zorn <federdaemn@mail.de>
#
# SPDX-License-Identifier: Apache-2.0
name: 'Build and push image'
# run workflow on every branch, only upload on main (allow manual trigger)
on: [push, pull_request, workflow_dispatch]
jobs:
build-push:
# only push branch main to registry
name: 'Build and push image'
# use ubuntu as runner
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup yq
uses: mikefarah/yq@v4
- name: Setup oras
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: oras-project/setup-oras@v1
- 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
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
with:
registry: ghcr.io
username: federdaemn
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
with:
username: federdaemn
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set outputs for later use
id: set-op
run: |
# extract version from ./values.yml
echo "software-version=$(yq '.version.software-version' ./anki-sync-server/values.yml)" \
>> $GITHUB_OUTPUT
# get current date+time
echo "time=$(date --utc +'%FT%TZ')" >> $GITHUB_OUTPUT
# get current date+time docker tag compatible
echo "time-docker=$(date --utc +'%Y-%m-%dt%H-%M-%Sz')" >> $GITHUB_OUTPUT
- name: Build and push image in production
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
with:
# directly push image
push: true
# use local repository
context: .
# which containerfile to build from
file: |
./anki-sync-server/containerfile
# build args to pass to the build
build-args: |
software_version=${{ steps.set-op.outputs.software-version }}
# build for many platforms at the same time
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
# set labels to append to the image
labels: |
# opencontainer labels specified
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
org.opencontainers.image.title="anki-sync-server"
org.opencontainers.image.description=Anki Sync Server (anki-sync-server) docker/oci container
org.opencontainers.image.authors=Frederik Zorn <federdaemn@mail.de>
org.opencontainers.image.created=${{ steps.set-op.outputs.time }}
org.opencontainers.image.version=${{ steps.set-op.outputs.software-version }}
org.opencontainers.image.source=https://github.com/federdaemn/container
org.opencontainers.image.licenses=AGPL-3.0-or-later
# artfifacthub labels specified
# https://artifacthub.io/docs/topics/repositories/container-images/#image-metadata
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/federdaemn/container/main/anki-sync-server/README.md
io.artifacthub.package.maintainers=[{"name":"federdaemn","email":"federdaemn@mail.de"}]
io.artifacthub.package.logo-url=https://raw.githubusercontent.com/federdaemn/container/main/anki-sync-server/imgs/ah-logo.png
io.artifacthub.package.alternative-locations=docker.io/federdaemn/anki-sync-server
io.artifacthub.package.keywords=anki,sync,server,anki-sync-server,anki-sync
# tags to build the image with
tags: |
ghcr.io/federdaemn/anki-sync-server:latest
ghcr.io/federdaemn/anki-sync-server:${{ steps.set-op.outputs.software-version }}
ghcr.io/federdaemn/anki-sync-server:${{ steps.set-op.outputs.time-docker }}
docker.io/federdaemn/anki-sync-server:latest
docker.io/federdaemn/anki-sync-server:${{ steps.set-op.outputs.software-version }}
docker.io/federdaemn/anki-sync-server:${{ steps.set-op.outputs.time-docker }}
- name: Build image in testing only
uses: docker/build-push-action@v5
if: github.event_name == 'pull_request'
with:
# do not push image
push: false
# use local repository
context: .
# which containerfile to build from
file: |
./anki-sync-server/containerfile
# build args to pass to the build
build-args: |
software_version=${{ steps.set-op.outputs.software-version }}
# build for many platforms at the same time
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
# use oras to push artifacthub metadata to registries
# source: https://artifacthub.io/docs/topics/repositories/container-images/#repository-metadata
- name: Push metadata
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
run: |
oras push \
ghcr.io/federdaemn/anki-sync-server:artifacthub.io \
--config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \
anki-sync-server/artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
oras push \
docker.io/federdaemn/anki-sync-server:artifacthub.io \
--config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \
anki-sync-server/artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml