0
0
docker-images/.gitea/workflows/searxng.yaml

66 lines
3.1 KiB
YAML
Raw Normal View History

2023-11-04 06:38:42 +08:00
name: searxng
2024-05-20 18:14:19 +08:00
run-name: searxng
2023-11-04 06:38:42 +08:00
env:
2024-06-17 10:42:07 +08:00
REPO_NAME: searxng
2024-05-20 18:14:19 +08:00
REMOTE_REPO: https://github.com/searxng/searxng.git
2023-11-04 06:38:42 +08:00
BUILD_PLATFORM: linux/arm64
on:
schedule:
- cron: "0 0 * * *" # at midnight
push:
paths:
2023-11-09 18:17:53 +08:00
- ".gitea/workflows/searxng.yaml"
2023-11-04 06:38:42 +08:00
jobs:
build-searxng:
runs-on: runner
container:
2024-06-17 10:42:07 +08:00
image: git.opnxng.com/opnxng/docker-buildx:latest
2023-11-04 06:38:42 +08:00
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)
2024-05-20 18:14:19 +08:00
LATEST_COMMIT=$(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1)
2023-11-04 06:38:42 +08:00
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
2024-06-17 10:42:07 +08:00
docker buildx create --use --name buildx
2023-11-04 06:38:42 +08:00
# 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
2024-05-20 18:14:19 +08:00
curl -JL https://git.opnxng.com/opnxng/docker-images/raw/branch/main/dockerfiles/searxng.Dockerfile -o Dockerfile
2024-06-17 10:42:07 +08:00
docker buildx build \
2023-11-04 06:38:42 +08:00
--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 || \
2023-11-11 18:04:44 +08:00
{ curl -H tags:warning -H prio:high -d "Built and pushed ${REPO_NAME} failed!" https://ntfy.opnxng.com/build ; exit 1; }
2023-11-04 06:38:42 +08:00
# Remove Docker Buildx builder
2024-06-17 10:42:07 +08:00
docker buildx rm buildx
2023-11-04 06:38:42 +08:00
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
2023-11-15 01:18:48 +08:00
fi