diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a91f5f3..274bcd7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,6 +31,7 @@ jobs: with: images: ghcr.io/${{ github.repository_owner }}/${{ inputs.app }} flavor: latest=true + tags: ${{ inputs.tags }} - name: Build and push images uses: docker/build-push-action@v5 @@ -45,6 +46,6 @@ jobs: uses: actions/delete-package-versions@v4 with: package-name: ${{ inputs.app }} - package-type: 'container' + package-type: "container" min-versions-to-keep: 5 - delete-only-untagged-versions: 'true' + delete-only-untagged-versions: "true" diff --git a/.github/workflows/sonarr.yml b/.github/workflows/sonarr.yml index e0cac7b..defa33a 100644 --- a/.github/workflows/sonarr.yml +++ b/.github/workflows/sonarr.yml @@ -3,17 +3,38 @@ name: Sonarr on: push: branches: - - main + - main paths: - - sonarr/Dockerfile + - sonarr/Dockerfile + schedule: + - cron: "0 3 * * *" workflow_dispatch: jobs: - call-main-workflow: - uses: ./.github/workflows/main.yml + check-version: + runs-on: ubuntu-latest permissions: contents: read packages: write - with: - app: sonarr + steps: + - name: Get release version + run: echo VERSION=$(curl -s https://services.sonarr.tv/v1/releases | jq -r '."v4-stable".version') >> $GITHUB_ENV + - name: Print release version + run: echo $VERSION + + - name: Compare to repo version + run: | + echo CHECK=$(curl -s -H "Authorization: Bearer $(echo -n ${{ secrets.GITHUB_TOKEN }} | base64)" https://ghcr.io/v2/${{ github.repository_owner }}/sonarr/tags/list | jq -r '.tags[]' | grep $VERSION || true) >> $GITHUB_ENV + + - name: Build image + # if: ${{ env.CHECK == '' || github.event_name == 'workflow_dispatch' }} + if: ${{ env.CHECK == '' }} + uses: ./.github/workflows/main.yml + with: + app: sonarr + tags: | + type=ref,event=branch + type=sha + type=raw,value=v4-stable + type=raw,value=${{ env.VERSION }}