diff --git a/.gitea/workflows/send.yaml b/.gitea/workflows/send.yaml new file mode 100644 index 0000000..75302b7 --- /dev/null +++ b/.gitea/workflows/send.yaml @@ -0,0 +1,66 @@ +name: send +run-name: send +env: + REPO_NAME: send + REMOTE_REPO: https://github.com/timvisee/send.git + BUILD_PLATFORM: linux/arm64 +on: + schedule: + - cron: "0 0 * * *" # at midnight + push: + paths: + - ".gitea/workflows/send.yaml" + - "dockerfiles/send.Dockerfile" + +jobs: + build: + 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/send.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/README.md b/README.md index 38548ed..6211198 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,10 @@ Source | Image [redlib-org/redlib](https://github.com/redlib-org/redlib) | opnxng/redlib (custom colours) [syeopite/priviblur](https://github.com/syeopite/priviblur) | opnxng/priviblur (custom colours) [rajatkulkarni95/hckrnws](https://github.com/rajatkulkarni95/hckrnws) | opnxng/hckrnews +[timvisee/send](https://github.com/timvisee/send) | opnxng/send(with clean-up rules) [zyachel/quetre](https://github.com/zyachel/quetre) | [pussthecatorg/quetre](https://quay.io/repository/pussthecatorg/quetre?tab=tags&tag=latest) [zyachel/libremdb](https://github.com/zyachel/libremdb) | [pussthecatorg/libremdb](https://quay.io/repository/pussthecatorg/libremdb?tab=tags&tag=latest) [cadence/breezewiki](https://gitdab.com/cadence/breezewiki) | [pussthecatorg/breezewiki](https://quay.io/repository/pussthecatorg/breezewiki?tab=tags&tag=latest) -[timvisee/send](https://github.com/timvisee/send) | [xavion-lux/send](https://gitlab.com/timvisee/send/-/merge_requests/31) [httpjamesm/AnonymousOverflow](https://github.com/httpjamesm/AnonymousOverflow) | [aryak/anonymousoverflow-docker-builds](https://codeberg.org/aryak/anonymousoverflow-docker-builds) [edwardloveall/Scribe](https://sr.ht/~edwardloveall/Scribe/) | [Lomanic/scribe-binaries](https://gitlab.com/Lomanic/scribe-binaries) [cadence/tube-meta](https://git.sr.ht/~cadence/tube-meta) | [abeltramo/cloudtube](https://github.com/ABeltramo/cloudtube-docker/tree/main) diff --git a/dockerfiles/send.Dockerfile b/dockerfiles/send.Dockerfile new file mode 100755 index 0000000..3f88a68 --- /dev/null +++ b/dockerfiles/send.Dockerfile @@ -0,0 +1,10 @@ +FROM ghcr.io/xavion-lux/send:latest + +USER root +RUN echo "find /uploads/ -name 7-\* -mmin +10130 -exec rm {} \;" > /etc/periodic/hourly/clean-up +RUN echo "find /uploads/ -name 1-\* -mmin +1500 -exec rm {} \;" >> /etc/periodic/hourly/clean-up +RUN chmod +x /etc/periodic/hourly/clean-up + +USER app +WORKDIR /app +CMD ["node", "server/bin/prod.js"]