diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index 43c456e..79ae72e 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -1,53 +1,36 @@ name: build-and-push-image on: - schedule: - - cron: '0 0 * * *' # Schedule to run once every day push: branches: - main -env: - CURRENT_RELEASE: v0.3.1 - jobs: build-multi-arch-image: name: Build multi-arch Docker image runs-on: ubuntu-latest steps: - - name: Check for new release - id: check_release - run: | - LATEST_RELEASE=$(curl -sL https://api.github.com/repos/vishen/go-chromecast/releases/latest | jq -r '.tag_name') - echo "release=$LATEST_RELEASE" >> $GITHUB_ENV - echo "CURRENT_RELEASE=${{ steps.check_release.outputs.release }}" >> $GITHUB_ENV - - name: Checkout - if: steps.check_release.outputs.release != env.CURRENT_RELEASE - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up QEMU - if: steps.check_release.outputs.release != env.CURRENT_RELEASE - uses: docker/setup-qemu-action@v1 - + uses: docker/setup-qemu-action@v2.1.0 + - name: Set up Docker Buildx - if: steps.check_release.outputs.release != env.CURRENT_RELEASE - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2.5.0 with: install: true - name: Login to GitHub Container Registry - if: steps.check_release.outputs.release != env.CURRENT_RELEASE - uses: docker/login-action@v1 + uses: docker/login-action@v2.1.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - if: steps.check_release.outputs.release != env.CURRENT_RELEASE - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4.0.0 with: - push: true + push: true tags: ghcr.io/${{ github.repository }}:latest platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 diff --git a/.github/workflows/check_for_new_go_chromecast.yml b/.github/workflows/check_for_new_go_chromecast.yml new file mode 100644 index 0000000..76311b7 --- /dev/null +++ b/.github/workflows/check_for_new_go_chromecast.yml @@ -0,0 +1,65 @@ +name: Check for new Go Chromecast version + +on: + schedule: + - cron: "0 0 * * *" # Schedule to run once every day + +jobs: + build-multi-arch-image: + name: Build multi-arch Docker image + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Get current go-chromecast version from Dockerfile + id: get-current-version + run: | + CURRENT_CHROMECASTGOVERSION=$(grep -oP '(?<=CHROMECASTGOVERSION=).*' ./Dockerfile) + echo "CURRENT_CHROMECASTGOVERSION=$CURRENT_CHROMECASTGOVERSION" >> $GITHUB_ENV + + - name: Get latest go-chromecast version + id: get-latest-version + run: | + LATEST_VERSION=$(curl -s "https://api.github.com/repos/vishen/go-chromecast/releases/latest" | jq -r '.tag_name') + echo "LATEST_CHROMECASTGOVERSION=$LATEST_VERSION" >> $GITHUB_ENV + + - name: Check if version is newer and update Dockerfile + id: check-version-and-update-dockerfile + run: | + if [[ "${{ env.CURRENT_CHROMECASTGOVERSION }}" == "${{ env.LATEST_CHROMECASTGOVERSION }}" ]]; then + echo "No new version available. Skipping Dockerfile update." + echo "VERSION_CHANGED=false" >> $GITHUB_ENV + else + echo "New version available. Updating Dockerfile." + echo "VERSION_CHANGED=true" >> $GITHUB_ENV + sed -i "s/ENV CHROMECASTGOVERSION=.*/ENV CHROMECASTGOVERSION=${{ env.LATEST_CHROMECASTGOVERSION }}/" ./Dockerfile + fi + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2.1.0 + if: ${{ env.VERSION_CHANGED == 'true' }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2.5.0 + with: + install: true + if: ${{ env.VERSION_CHANGED == 'true' }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.1.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + if: ${{ env.VERSION_CHANGED == 'true' }} + + - name: Build and push + uses: docker/build-push-action@v4.0.0 + with: + push: true + context: . + tags: ghcr.io/${{ github.repository }}:latest + platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 + file: ./Dockerfile + if: ${{ env.VERSION_CHANGED == 'true' }} diff --git a/Dockerfile b/Dockerfile index ad5c28b..5c43538 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,14 @@ FROM alpine:latest ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT +ENV CHROMECASTGOVERSION=v0.3.1 RUN apk --no-cache add jq bc grep curl \ - && GC_URL=`wget https://api.github.com/repos/vishen/go-chromecast/releases/latest -O - | jq -r '.assets[].browser_download_url' | grep ${TARGETOS}_${TARGETARCH}${TARGETVARIANT}` \ - && wget $GC_URL -O /root/go-chromecast.tgz \ - && tar xzf /root/go-chromecast.tgz -C /usr/bin \ - && rm -rf /root/* \ - && chmod +x /usr/bin/go-chromecast + && GC_URL=`wget https://api.github.com/repos/vishen/go-chromecast/releases/tags/${CHROMECASTGOVERSION} -O - | jq -r '.assets[].browser_download_url' | grep ${TARGETOS}_${TARGETARCH}${TARGETVARIANT}` \ + && wget $GC_URL -O /root/go-chromecast.tgz \ + && tar xzf /root/go-chromecast.tgz -C /usr/bin \ + && rm -rf /root/* \ + && chmod +x /usr/bin/go-chromecast ENV SBCPOLLINTERVAL 1 ENV SBCSCANINTERVAL 300 @@ -22,3 +23,4 @@ LABEL Description="Container to run go-chromecast with some preset ENVs, run as ADD sponsorblockcast.sh /usr/bin/sponsorblockcast CMD /usr/bin/sponsorblockcast + diff --git a/docker-compose.yaml b/docker-compose.yaml index e683832..28b3617 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,3 +11,8 @@ services: cap_add: - NET_ADMIN restart: always + healthcheck: + test: ["CMD", "go-chromecast", "ls"] + interval: 60s + timeout: 10s + retries: 3