Deploy Images to GHCR when a new version is detected #16750
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Images to GHCR when a new version is detected | |
| on: | |
| schedule: | |
| - cron: "0 * * * *" | |
| workflow_dispatch: | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| trigger_workflow: ${{ steps.compare_versions.outputs.trigger_workflow }} | |
| current_version: ${{ steps.compare_versions.outputs.current_version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Compare versions | |
| id: compare_versions | |
| run: | | |
| PREVIOUS_VERSION_JSON=`cat version.json` | |
| CURRENT_VERSION_JSON=`curl -s https://plexamp.plex.tv/headless/version.json` | |
| CURRENT_VERSION=`echo $CURRENT_VERSION_JSON | jq -r .latestVersion` | |
| if [ "$PREVIOUS_VERSION_JSON" != "$CURRENT_VERSION_JSON" ]; then | |
| echo "trigger_workflow=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "trigger_workflow=false" >> $GITHUB_OUTPUT | |
| fi | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| build-amd64: | |
| needs: check-version | |
| if: needs.check-version.outputs.trigger_workflow == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{github.actor}} | |
| password: ${{secrets.GITHUB_TOKEN}} | |
| - name: Build AMD64 image | |
| run: | | |
| docker buildx create --use | |
| docker buildx build --platform linux/amd64 -t ghcr.io/${{github.actor}}/plexamp:amd64 --push . | |
| docker buildx build --platform linux/amd64 -t ghcr.io/${{github.actor}}/plexamp:amd64-${{ needs.check-version.outputs.current_version }} --push . | |
| build-arm64: | |
| needs: check-version | |
| if: needs.check-version.outputs.trigger_workflow == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{github.actor}} | |
| password: ${{secrets.GITHUB_TOKEN}} | |
| - name: Build ARM64 image | |
| run: | | |
| docker buildx create --use | |
| docker buildx build --platform linux/arm64 -t ghcr.io/${{github.actor}}/plexamp:arm64v8 --push . | |
| docker buildx build --platform linux/arm64 -t ghcr.io/${{github.actor}}/plexamp:arm64v8-${{ needs.check-version.outputs.current_version }} --push . | |
| build-arm32: | |
| needs: check-version | |
| if: needs.check-version.outputs.trigger_workflow == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{github.actor}} | |
| password: ${{secrets.GITHUB_TOKEN}} | |
| - name: Build ARM32v7 image | |
| run: | | |
| docker buildx create --use | |
| docker buildx build --platform linux/arm/v7 -f Dockerfile.arm32v7 -t ghcr.io/${{github.actor}}/plexamp:arm32v7 --push . | |
| docker buildx build --platform linux/arm/v7 -f Dockerfile.arm32v7 -t ghcr.io/${{github.actor}}/plexamp:arm32v7-${{ needs.check-version.outputs.current_version }} --push . | |
| create-manifests: | |
| needs: [check-version, build-amd64, build-arm64, build-arm32] | |
| if: needs.check-version.outputs.trigger_workflow == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{github.actor}} | |
| password: ${{secrets.GITHUB_TOKEN}} | |
| - name: Create multi-arch manifests | |
| run: | | |
| docker buildx imagetools create -t ghcr.io/${{github.actor}}/plexamp:latest \ | |
| ghcr.io/${{github.actor}}/plexamp:amd64 \ | |
| ghcr.io/${{github.actor}}/plexamp:arm64v8 \ | |
| ghcr.io/${{github.actor}}/plexamp:arm32v7 | |
| docker buildx imagetools create -t ghcr.io/${{github.actor}}/plexamp:${{ needs.check-version.outputs.current_version }} \ | |
| ghcr.io/${{github.actor}}/plexamp:amd64-${{ needs.check-version.outputs.current_version }} \ | |
| ghcr.io/${{github.actor}}/plexamp:arm64v8-${{ needs.check-version.outputs.current_version }} \ | |
| ghcr.io/${{github.actor}}/plexamp:arm32v7-${{ needs.check-version.outputs.current_version }} | |
| create-release: | |
| needs: [check-version, create-manifests] | |
| if: needs.check-version.outputs.trigger_workflow == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ needs.check-version.outputs.current_version }} | |
| name: Plexamp ${{ needs.check-version.outputs.current_version }} | |
| body: | | |
| ## Multi-architecture Docker images for Plexamp ${{ needs.check-version.outputs.current_version }} | |
| ### Images available: | |
| - `ghcr.io/${{ github.actor }}/plexamp:latest` (multi-arch: amd64, arm64, arm32v7) | |
| - `ghcr.io/${{ github.actor }}/plexamp:${{ needs.check-version.outputs.current_version }}` (multi-arch: amd64, arm64, arm32v7) | |
| - `ghcr.io/${{ github.actor }}/plexamp:amd64-${{ needs.check-version.outputs.current_version }}` | |
| - `ghcr.io/${{ github.actor }}/plexamp:arm64v8-${{ needs.check-version.outputs.current_version }}` | |
| - `ghcr.io/${{ github.actor }}/plexamp:arm32v7-${{ needs.check-version.outputs.current_version }}` | |
| ### Base Images: | |
| - **AMD64/ARM64**: Debian Trixie (latest security updates) | |
| - **ARM32v7**: Debian Bookworm (for ARM32v7 compatibility) | |
| For usage instructions, see the [README](https://github.com/${{ github.repository }}/blob/main/README.md). | |
| draft: false | |
| prerelease: false | |
| update-version: | |
| needs: [check-version, create-release] | |
| if: needs.check-version.outputs.trigger_workflow == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Update local version | |
| run: | | |
| CURRENT_VERSION_JSON=`curl -s https://plexamp.plex.tv/headless/version.json` | |
| echo $CURRENT_VERSION_JSON > version.json | |
| git config --global user.name "Version updater" | |
| git config --global user.email "edd933a9@duck.com" | |
| git commit -am "upd: version bump to ${{ needs.check-version.outputs.current_version }}" | |
| git push |