From 057afd36c681b5c73310263da8ea6ff89ff94e79 Mon Sep 17 00:00:00 2001 From: Opnxng Date: Wed, 9 Oct 2024 12:26:21 +0800 Subject: [PATCH] Added Priviblur --- .gitea/workflows/priviblur.yaml | 65 ++++++++++++++++++++++++++++++++ dockerfiles/priviblur.Dockerfile | 17 +++++++++ 2 files changed, 82 insertions(+) create mode 100644 .gitea/workflows/priviblur.yaml create mode 100644 dockerfiles/priviblur.Dockerfile diff --git a/.gitea/workflows/priviblur.yaml b/.gitea/workflows/priviblur.yaml new file mode 100644 index 0000000..ba94fe3 --- /dev/null +++ b/.gitea/workflows/priviblur.yaml @@ -0,0 +1,65 @@ +name: priviblur +run-name: priviblur +env: + REPO_NAME: priviblur + REMOTE_REPO: https://github.com/syeopite/priviblur.git + BUILD_PLATFORM: linux/arm64 +on: + schedule: + - cron: "0 0 * * *" # at midnight + push: + paths: + - ".gitea/workflows/priviblur.yaml" + +jobs: + build-priviblur: + runs-on: runner + container: + image: git.opnxng.com/opnxng/docker-buildx:latest + steps: + - name: Check latest upstream commit + run: | + STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1) + LATEST_COMMIT=$(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1) + echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV" + echo "LATEST_COMMIT=${LATEST_COMMIT}" >> "$GITHUB_ENV" + echo "Stored Commit: ${STORED_COMMIT}" + echo "Latest Commit: ${LATEST_COMMIT}" + + - name: Build and push Docker image + run: | + if [ "$STORED_COMMIT" != "$LATEST_COMMIT" ]; then + echo "Found a new commit, building new image" + # Create and use Docker Buildx builder + docker buildx create --use --name buildx + # Login to Package Registry + echo "${{ secrets.TOKEN }}" | docker login git.opnxng.com -u ${{ gitea.repository_owner }} --password-stdin + # Build and push Docker image + mkdir temp + cd temp + curl -JL https://git.opnxng.com/opnxng/docker-images/raw/branch/main/dockerfiles/priviblur.Dockerfile -o Dockerfile + docker buildx build \ + --platform ${BUILD_PLATFORM} \ + -t git.opnxng.com/${{ gitea.repository_owner }}/${REPO_NAME}:latest \ + -f ./Dockerfile \ + --push . && \ + curl -H prio:low -d "Built and pushed ${REPO_NAME}" https://ntfy.opnxng.com/build || \ + { curl -H tags:warning -H prio:high -d "Built and pushed ${REPO_NAME} failed!" https://ntfy.opnxng.com/build ; exit 1; } + # Remove Docker Buildx builder + docker buildx rm buildx + else + echo "No new commit, skipped build" + fi + + - name: Update stored commit + run: | + if [ "$STORED_COMMIT" != "$LATEST_COMMIT" ]; then + curl -H "Authorization: Bearer ${{ secrets.NT }}" -d $(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1) "https://nt.opnxng.com/${REPO_NAME}" + STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1) + echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV" + else + curl -H "Authorization: Bearer ${{ secrets.NT }}" -d $(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1) "https://nt.opnxng.com/${REPO_NAME}" + STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1) + echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV" + exit 1 + fi diff --git a/dockerfiles/priviblur.Dockerfile b/dockerfiles/priviblur.Dockerfile new file mode 100644 index 0000000..59e85de --- /dev/null +++ b/dockerfiles/priviblur.Dockerfile @@ -0,0 +1,17 @@ +FROM quay.io/pussthecatorg/priviblur + +# Use sed to replace the colors in base.css +RUN sed -i 's/--color-primary-900: hsl(25, 100%, 15%);/--color-primary-900: hsl(210, 60%, 10%);/' ./assets/css/base.css && \ + sed -i 's/--color-primary-800: hsl(27, 50%, 30%);/--color-primary-800: hsl(210, 50%, 20%);/' ./assets/css/base.css && \ + sed -i 's/--color-primary-700: hsl(30, 50%, 40%);/--color-primary-700: hsl(210, 50%, 30%);/' ./assets/css/base.css && \ + sed -i 's/--color-primary-600: hsl(33, 70%, 45%);/--color-primary-600: hsl(210, 50%, 40%);/' ./assets/css/base.css && \ + sed -i 's/--color-primary-500: hsl(36, 80%, 50%);/--color-primary-500: hsl(210, 50%, 50%);/' ./assets/css/base.css && \ + sed -i 's/--color-primary-400: hsl(36, 90%, 60%);/--color-primary-400: hsl(210, 45%, 60%);/' ./assets/css/base.css && \ + sed -i 's/--color-primary-300: hsl(36, 100%, 70%);/--color-primary-300: hsl(210, 40%, 70%);/' ./assets/css/base.css && \ + sed -i 's/--color-primary-200: hsl(36, 100%, 85%);/--color-primary-200: hsl(210, 30%, 80%);/' ./assets/css/base.css && \ + sed -i 's/--color-primary-100: hsl(36, 100%, 95%);/--color-primary-100: hsl(210, 20%, 90%);/' ./assets/css/base.css + +EXPOSE 8000 +USER priviblur +ENTRYPOINT [ "/sbin/tini", "--"] +CMD [ "python", "-m", "src.server" ]