docker-qbittorrent/.github/workflows/auto-update.yml

79 lines
2.4 KiB
YAML

name: update-bot
on:
schedule:
- cron: '50 23 * * *'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/qbittorrent
jobs:
check:
runs-on: ubuntu-latest
outputs:
old_ver: ${{ steps.check_ver.outputs.old_ver }}
new_ver: ${{ steps.check_ver.outputs.new_ver }}
steps:
- name: Check version
id: check_ver
run: |
get_ver() (curl -s "$@" | grep -Po "(\d+\.)+\d+\-r\d+" | head -1)
OLD_VER=$(get_ver ${GHCO_URL})
NEW_VER=$(get_ver ${ALPINE_PKG_URL})
echo "::set-output name=old_ver::${OLD_VER}"
echo "::set-output name=new_ver::${NEW_VER}"
env:
ALPINE_PKG_URL: https://pkgs.alpinelinux.org/package/edge/testing/x86_64/qbittorrent-nox
GHCO_URL: https://github.com/mogeko/docker-qbittorrent/pkgs/container/qbittorrent
build:
runs-on: ubuntu-latest
needs: check
if: ${{ needs.check.outputs.old_ver != needs.check.outputs.new_ver }}
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@548e2346a9987b56d8a4104fe776321ff8e23440
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge
type=schedule,pattern={{date 'YYYYMMDD'}}
type=raw,${{ needs.check.outputs.new_ver }}
type=raw,latest
- name: Build and push Docker image
id: build
uses: docker/build-push-action@a66e35b9cbcf4ad0ea91ffcaf7bbad63ad9e0229
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ needs.check.outputs.new_ver }}
- name: Save metadata
run: echo ${{ toJSON(steps.build.outputs.metadata) }} > ${{ github.workspace }}/meta.json
- name: Update metadata
uses: actions/upload-artifact@v2
with:
name: metadata
path: ${{ github.workspace }}/meta.json