Skip to content

URL_PREFIX support

URL_PREFIX support #1

name: DockerGHCR-Release
on:
schedule:
- cron: '0 3 * * *'
push:
branches:
- main
paths:
- 'Dockerfile'
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
REGISTRY_TAG: latest
WEBREPO: "https://github.com/Stremio/stremio-web.git"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
check_release:
runs-on: ubuntu-latest
outputs:
id: ${{steps.check.outputs.continue }}
version: ${{steps.check.outputs.version }}
steps:
- name: CheckRelease
id: check
run: |
TAG=$(git ls-remote --tags --refs ${{ env.WEBREPO }} | tail -n1 | cut -d/ -f3)
URL=$(wget https://raw.githubusercontent.com/Stremio/stremio-shell/master/server-url.txt -O server-url.txt; cat server-url.txt)
BODY=$(curl -s https://api.github.com/repos/zaarrg/stremio-docker-prefix/releases/latest | grep body | awk -F\" '{print $4}')
OLDTAG=$(echo $BODY | awk '{print $3}')
OLDURL=$(echo $BODY | awk '{print $7}')
if [ "$TAG" == "$OLDTAG" ]; then
echo "${TAG} is the same as ${OLDTAG} "
else
echo "We need to release. Found new tag ${TAG}"
RELEASE="true"
fi
if [ "$URL" == "$OLDURL" ]; then
echo "${URL} is the same as ${OLDURL}"
else
echo "We need to release. Found new url ${URL}"
RELEASE="true"
fi
if [ "$RELEASE" ]; then
VERSION=$(curl -s https://api.github.com/repos/zaarrg/stremio-docker-prefix/releases/latest | grep \"name\" | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+')
NEWVERSION=${VERSION:0:-1}$((${VERSION: -1}+1))
echo "We need to release $NEWVERSION"
echo "version=$NEWVERSION" >> $GITHUB_OUTPUT
echo "continue=true" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs:
- check_release
if: ${{ needs.check_release.outputs.id }}
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "TAG=${{ env.REGISTRY_IMAGE }}:${platform//\//-}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and Push to GHCR
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ matrix.platform }}
tags: |
${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}
${{ env.REGISTRY_IMAGE }}:${{ needs.check_release.outputs.version }}
build-args: |
BRANCH=release
VERSION=${{ env.TAG_NAME }}
push: true
release:
runs-on: ubuntu-latest
if: ${{ needs.check_release.outputs.id }}
needs:
- build
- check_release
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create GitHub Release
run: |
TAG=$(git ls-remote --tags --refs ${{ env.WEBREPO }} | tail -n1 | cut -d/ -f3)
URL=$(wget https://raw.githubusercontent.com/Stremio/stremio-shell/master/server-url.txt -O server-url.txt; cat server-url.txt)
gh release create ${{ needs.check_release.outputs.version }} --title "Release ${{ needs.check_release.outputs.version }}" --notes "Web version ${TAG} - Server url ${URL} "