Skip to content

chore(anki-sync-server): bump version to 23.10.1 #65

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

chore(anki-sync-server): bump version to 23.10.1 #65

# 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
# set labels to append to the image
labels: |
org.opencontainers.image.created=${{ steps.set-op.outputs.time }}
org.opencontainers.image.version=${{ steps.set-op.outputs.software-version }}
# 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
# 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