0
0

Added Priviblur

This commit is contained in:
Opnxng 2024-10-09 12:26:21 +08:00
parent 013d9752ff
commit dccc484578
3 changed files with 87 additions and 2 deletions

View File

@ -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

View File

@ -0,0 +1,18 @@
# Base image credits to TheFrenchGhosty
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" ]

View File

@ -9,9 +9,11 @@ RUN apk add --no-cache curl git musl-dev
# Clone the redlib repository and build # Clone the redlib repository and build
RUN git clone https://github.com/redlib-org/redlib && \ RUN git clone https://github.com/redlib-org/redlib && \
cd redlib && \ cd redlib && \
sed -i 's/--accent: red;/--accent: #4385BE;/g' static/style.css && \
sed -i 's/--accent: #9a0000;/--accent: #4385BE;/g' static/style.css && \
sed -i 's/#9a0000/#4385BE/g' static/themes/light.css && \ sed -i 's/#9a0000/#4385BE/g' static/themes/light.css && \
sed -i 's/#9a0000/#205EA6/g' static/themes/black.css && \ sed -i 's/#9a0000/#4385BE/g' static/themes/black.css && \
sed -i 's/red/#205EA6/g' static/themes/dark.css && \ sed -i 's/red/#4385BE/g' static/themes/dark.css && \
cargo build --release --target=${TARGET} && \ cargo build --release --target=${TARGET} && \
cp target/${TARGET}/release/redlib /usr/local/bin/redlib && \ cp target/${TARGET}/release/redlib /usr/local/bin/redlib && \
cd .. && \ cd .. && \