name: update-bot on: schedule: - cron: '30 23 * * *' 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: | OLD_TAG=$(curl -s "${GHCO_URL}" | grep -Po "(\d+\.)+\d+\-r\d+" | head -1) NEW_TAG=$(curl -s "${REPO_TAGS}" | grep -Po "release-(\d+\.){2}\d+\.zip" | head -1) echo "::set-output name=old_ver::${OLD_TAG:0:5}" echo "::set-output name=new_ver::${NEW_TAG:8:5}" env: GHCO_URL: https://github.com/mogeko/docker-qbittorrent/pkgs/container/qbittorrent REPO_TAGS: https://github.com/qbittorrent/qBittorrent/tags 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 Docker Hub uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Log in to the Container registry uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@548e2346a9987b56d8a4104fe776321ff8e23440 with: images: | ${{ github.repository_owner }}/qbittorrent ghcr.io/${{ github.repository_owner }}/qbittorrent 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: | QBITTORRENT_VERSION=${{ needs.check.outputs.new_ver }}-r0 LIBTORRENT_VERSION=1.2.14 - 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