Skip to content

[chore] Bump Python version to match Borgmatic and update dependencies #203

[chore] Bump Python version to match Borgmatic and update dependencies

[chore] Bump Python version to match Borgmatic and update dependencies #203

Workflow file for this run

name: Build Image
on:
push:
tags:
- 'v*.*.*'
- 'latest'
pull_request:
branches:
- 'master'
- 'main'
paths-ignore:
- 'README.md'
workflow_dispatch:
inputs:
borgmatic-image-version:
description: 'Borgmatic base image version:'
required: true
default: 'latest'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
BORGMATIC_IMAGE_VERSION: ${{ github.event.inputs.borgmatic-image-version || 'latest' }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.14.3
- name: Check Coverage
run: |
pip install poetry
poetry config virtualenvs.create false
poetry install --no-root --with dev
pytest --cov
lint:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
statuses: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
# https://github.com/marketplace/actions/super-linter
- name: Super-Linter
uses: super-linter/super-linter@v5.7.2
env:
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_PYTHON_BLACK: true
VALIDATE_PYTHON_PYLINT: true
build:
needs:
- lint
- test
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
# https://github.com/marketplace/actions/docker-setup-qemu
- name: Setup QEMU
uses: docker/setup-qemu-action@v3.0.0
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3.0.0
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Borgmatic Image Version
if: ${{ env.BORGMATIC_IMAGE_VERSION == 'latest' }}
id: borgmatic-version
run: |
LATEST_VERSION=$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s https://api.github.com/orgs/borgmatic-collective/packages/container/borgmatic/versions | jq -r '[.[] | .metadata.container.tags[]? | select(test("^[0-9]+\\.[0-9]+\\.[0-9]+$"))] | unique | sort_by(split(".") | map(tonumber)) | last' )
echo "BORGMATIC_IMAGE_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
# https://github.com/marketplace/actions/docker-metadata-action
- name: Meta
id: meta
uses: docker/metadata-action@v5.5.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=raw,event=pr,value=dev
annotations: |
org.opencontainers.image.base.name=borgmatic:${{ env.BORGMATIC_IMAGE_VERSION }}
org.opencontainers.image.title=Borgmatic Exporter
org.opencontainers.image.description=Official Borgmatic image bundled with the Prometheus exporter
- name: Inspect Tags
run: echo "${{ steps.meta.outputs.tags }}"
- name: Inspect Labels
run: echo "${{ steps.meta.outputs.labels }}"
- name: Inspect Annotations
run: echo "${{ steps.meta.outputs.annotations }}"
# https://github.com/marketplace/actions/build-and-push-docker-images
- name: Build and push Docker images
uses: docker/build-push-action@v5.1.0
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
platforms: linux/amd64, linux/arm64
annotations: ${{ steps.meta.outputs.annotations }}
build-args: BORGMATIC_IMAGE_VERSION=${{ env.BORGMATIC_IMAGE_VERSION }}
- name: Checkout Code
uses: actions/checkout@v4
- name: Update README Badge
if: ${{ success() && github.ref_type != 'tag' }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin
git checkout $GITHUB_HEAD_REF
sed -i "s/Borgmatic%20Image-v[0-9.]*-green/Borgmatic%20Image-v${{ env.BORGMATIC_IMAGE_VERSION }}-green/" README.md
git add README.md
git diff --cached --quiet || git commit -m "Update badge with Borgmatic Image version ${{ env.BORGMATIC_IMAGE_VERSION }}"
git push origin $GITHUB_HEAD_REF
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}