DockerHub-Release #669
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: DockerHub-Release | |
on: | |
workflow_dispatch: | |
inputs: | |
INPUT_VERSION: | |
description: 'New version to release' | |
required: true | |
default: '' | |
schedule: | |
- cron: "0 3 * * *" | |
push: | |
branches: | |
- main | |
paths: | |
- "Dockerfile" | |
env: | |
TMP_LOCAL_IMAGE: localhost:5000/${{ github.repository }} | |
REGISTRY_IMAGE: ${{ 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 }} | |
INPUT_VERSION: ${{ github.event.inputs.INPUT_VERSION }} | |
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 }} | awk '{print $2}' | sort -V | 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/tsaridas/stremio-docker/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 [ -n "${INPUT_VERSION}" ]; then | |
echo "We need to release ${INPUT_VERSION}" | |
NEWVERSION=${INPUT_VERSION} | |
echo "version=$NEWVERSION" >> $GITHUB_OUTPUT | |
echo "continue=true" >> $GITHUB_OUTPUT | |
elif [ "$RELEASE" ]; then | |
VERSION=$(curl -s https://api.github.com/repos/tsaridas/stremio-docker/releases/latest | grep \"name | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+') | |
NEWVERSION=$(echo $VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') | |
echo "We need to release $NEWVERSION" | |
echo "version=$NEWVERSION" >> $GITHUB_OUTPUT | |
echo "continue=true" >> $GITHUB_OUTPUT | |
fi | |
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 | |
- linux/ppc64le | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Prepare | |
run: | | |
mkdir -p /tmp/images | |
platform=${{ matrix.platform }} | |
echo "TARFILE=${platform//\//-}.tar" >> $GITHUB_ENV | |
echo "TAG=${{ env.TMP_LOCAL_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 | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
tags: ${{ env.TAG }} | |
build-args: | | |
BRANCH=release | |
VERSION=${{ env.TAG_NAME }} | |
outputs: type=docker,dest=/tmp/images/${{ env.TARFILE }} | |
- name: Load images | |
run: | | |
for image in /tmp/images/*.tar; do | |
docker load -i $image | |
done | |
- name: Setup environment | |
run: | | |
npm install @playwright/test | |
npx playwright install --with-deps | |
docker network create --subnet=172.18.0.0/24 custom_network | |
echo "172.18.0.3 172-18-0-3.519b6502d940.stremio.rocks" | sudo tee -a /etc/hosts | |
- name: Run Docker Container and Test (1st run) | |
run: | | |
platform=${{ matrix.platform }} | |
docker run -d --network custom_network --ip 172.18.0.3 -e NO_CORS=1 -e CASTING_DISABLED=1 --platform ${{ matrix.platform }} ${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-} | |
cd tests | |
sleep 15 # wait for server to startup | |
CONTAINER_ID=$(docker ps -a | grep stremio | awk '{print $1}') | |
docker exec "$CONTAINER_ID" cat /etc/nginx/http.d/default.conf | |
docker exec "$CONTAINER_ID" ps aux | |
docker logs "$CONTAINER_ID" | |
npx playwright test settings.spec --timeout=60000 || ( | |
docker ps -a; | |
docker logs "$CONTAINER_ID"; | |
exit 1; | |
) | |
docker logs "$CONTAINER_ID"; | |
docker stop "$CONTAINER_ID" | |
docker rm "$CONTAINER_ID" | |
- name: Run Docker Container and Test (with http 11470) | |
run: | | |
platform=${{ matrix.platform }} | |
docker run -d --network custom_network --ip 172.18.0.3 -e NO_CORS=1 -e CASTING_DISABLED=1 --platform ${{ matrix.platform }} ${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-} | |
cd tests | |
sleep 15 # wait for server to startup | |
CONTAINER_ID=$(docker ps -a | grep stremio | awk '{print $1}') | |
docker exec "$CONTAINER_ID" cat /etc/nginx/http.d/default.conf | |
docker exec "$CONTAINER_ID" ps aux | |
docker logs "$CONTAINER_ID" | |
SERVER_URL="http://172.18.0.3:11470" npx playwright test settings.spec --timeout=60000 || ( | |
docker ps -a; | |
docker logs "$CONTAINER_ID"; | |
exit 1; | |
) | |
docker logs "$CONTAINER_ID"; | |
docker stop "$CONTAINER_ID" | |
docker rm "$CONTAINER_ID" | |
- name: Run Docker Container and Test (with IPADDRESS) | |
run: | | |
platform=${{ matrix.platform }} | |
docker run -d --network custom_network --ip 172.18.0.3 -e CASTING_DISABLED=1 -e IPADDRESS=172.18.0.3 -v ~/.stremio-server:/root/.stremio-server --platform ${{ matrix.platform }} ${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-} | |
cd tests | |
sleep 60 # wait longer for server to startup | |
CONTAINER_ID=$(docker ps -a | grep stremio | awk '{print $1}') | |
docker exec "$CONTAINER_ID" cat /etc/nginx/http.d/default.conf | |
docker exec "$CONTAINER_ID" ps aux | |
docker logs "$CONTAINER_ID" | |
WEB_URL="https://172-18-0-3.519b6502d940.stremio.rocks:8080" SERVER_URL="https://172-18-0-3.519b6502d940.stremio.rocks:8080" npx playwright test settings.spec --timeout=60000 || ( | |
docker ps -a; | |
docker logs "$CONTAINER_ID"; | |
exit 1; | |
) | |
echo "--------------------------------" | |
WEB_URL="https://172-18-0-3.519b6502d940.stremio.rocks:8080" SERVER_URL="https://172-18-0-3.519b6502d940.stremio.rocks:12470" npx playwright test settings.spec --timeout=60000 || ( | |
docker ps -a; | |
docker logs "$CONTAINER_ID"; | |
exit 1; | |
) | |
echo "--------------------------------" | |
docker logs "$CONTAINER_ID" | |
docker stop "$CONTAINER_ID" | |
docker rm "$CONTAINER_ID" | |
- name: Run Docker Container and Test (with SERVER_URL) | |
run: | | |
platform=${{ matrix.platform }} | |
docker run -d --network custom_network --ip 172.18.0.3 -e NO_CORS=1 -e CASTING_DISABLED=1 -e SERVER_URL="http://172.18.0.3:8080/" --platform ${{ matrix.platform }} ${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-} | |
cd tests | |
sleep 15 # wait for server to startup | |
CONTAINER_ID=$(docker ps -a | grep stremio | awk '{print $1}') | |
docker exec "$CONTAINER_ID" cat /etc/nginx/http.d/default.conf | |
docker exec "$CONTAINER_ID" ps aux | |
docker logs "$CONTAINER_ID" | |
npx playwright test settings_server_url.spec --timeout=60000 || ( | |
docker ps -a; | |
docker logs "$CONTAINER_ID"; | |
exit 1; | |
) | |
docker logs "$CONTAINER_ID"; | |
docker stop "$CONTAINER_ID" | |
docker rm "$CONTAINER_ID" | |
- name: Run Docker Container and Test (with AUTO_SERVER_URL) | |
run: | | |
platform=${{ matrix.platform }} | |
docker run -d --network custom_network --ip 172.18.0.3 -e NO_CORS=1 -e CASTING_DISABLED=1 -e AUTO_SERVER_URL=1 --platform ${{ matrix.platform }} ${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-} | |
cd tests | |
sleep 15 # wait for server to startup | |
CONTAINER_ID=$(docker ps -a | grep stremio | awk '{print $1}') | |
docker exec "$CONTAINER_ID" cat /etc/nginx/http.d/default.conf | |
docker exec "$CONTAINER_ID" ps aux | |
docker logs "$CONTAINER_ID" | |
npx playwright test settings_server_url.spec --timeout=60000 || ( | |
docker ps -a; | |
docker logs "$CONTAINER_ID"; | |
exit 1; | |
) | |
docker logs "$CONTAINER_ID"; | |
docker stop "$CONTAINER_ID" | |
docker rm "$CONTAINER_ID" | |
- name: Run Docker Container and Test (with WEBUI_LOCATION and WEBUI_INTERNAL_PORT) | |
run: | | |
platform=${{ matrix.platform }} | |
docker run -d --network custom_network --ip 172.18.0.3 -e NO_CORS=1 -e CASTING_DISABLED=1 -e WEBUI_INTERNAL_PORT=9090 --platform ${{ matrix.platform }} ${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-} | |
cd tests | |
sleep 15 # wait for server to startup | |
CONTAINER_ID=$(docker ps -a | grep stremio | awk '{print $1}') | |
docker exec "$CONTAINER_ID" cat /etc/nginx/http.d/default.conf | |
docker exec "$CONTAINER_ID" ps aux | |
docker logs "$CONTAINER_ID" | |
WEB_URL="http://172.18.0.3:9090" SERVER_URL="http://172.18.0.3:9090" npx playwright test settings.spec --timeout=60000 || ( | |
docker ps -a; | |
docker logs "$CONTAINER_ID"; | |
exit 1; | |
) | |
docker logs "$CONTAINER_ID"; | |
docker stop "$CONTAINER_ID" | |
docker rm "$CONTAINER_ID" | |
- name: Run Docker Container and Test (with basic auth) | |
run: | | |
platform=${{ matrix.platform }} | |
docker run -d --network custom_network --ip 172.18.0.3 -e NO_CORS=1 -e USERNAME=default_user -e PASSWORD=default_pass -e CASTING_DISABLED=1 --platform ${{ matrix.platform }} ${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-} | |
cd tests | |
sleep 15 # wait for server to startup | |
CONTAINER_ID=$(docker ps -a | grep stremio | awk '{print $1}') | |
docker exec "$CONTAINER_ID" cat /etc/nginx/http.d/default.conf | |
docker exec "$CONTAINER_ID" ps aux | |
docker logs "$CONTAINER_ID" | |
AUTH=true npx playwright test settings.spec --timeout=60000 || ( | |
docker ps -a; | |
docker logs "$CONTAINER_ID"; | |
exit 1; | |
) | |
docker logs "$CONTAINER_ID"; | |
docker stop "$CONTAINER_ID" | |
docker rm "$CONTAINER_ID" | |
- name: Upload image | |
uses: actions/upload-artifact@v4 | |
with: | |
name: images-${{ strategy.job-index }} | |
path: /tmp/images/${{ env.TARFILE }} | |
if-no-files-found: error | |
retention-days: 1 | |
push: | |
runs-on: ubuntu-latest | |
if: ${{ needs.check_release.outputs.id }} | |
needs: | |
- build | |
- check_release | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
steps: | |
- name: Download images | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: images-* | |
merge-multiple: true | |
path: /tmp/images | |
- name: Load images | |
run: | | |
for image in /tmp/images/*.tar; do | |
docker load -i $image | |
done | |
- name: Push images to local registry | |
run: | | |
docker push -a ${{ env.TMP_LOCAL_IMAGE }} | |
- name: Login to DockerHUB | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASS }} | |
- name: Create manifest list and push | |
run: | | |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }} -t ${{ env.REGISTRY_IMAGE }}:${{ needs.check_release.outputs.version }} \ | |
$(docker image ls --format '{{.Repository}}:{{.Tag}}' '${{ env.TMP_LOCAL_IMAGE }}' | tr '\n' ' ') | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }} | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ needs.check_release.outputs.version }} | |
release: | |
runs-on: ubuntu-latest | |
if: ${{ needs.check_release.outputs.id }} | |
needs: | |
- build | |
- push | |
- check_release | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Release | |
run: | | |
TAG=$(git ls-remote --tags --refs ${{ env.WEBREPO }} | awk '{print $2}' | sort -V | 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} " |