From 26e7fadb6cb7238ff48b6f0eb40a4bc73312eafe Mon Sep 17 00:00:00 2001 From: Amir Husayn Panahifar Date: Fri, 6 Nov 2026 11:09:41 +0330 Subject: [PATCH] ci: regenerate the profile daily with Gitea Actions --- .gitea/workflows/update-profile.yml | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .gitea/workflows/update-profile.yml diff --git a/.gitea/workflows/update-profile.yml b/.gitea/workflows/update-profile.yml new file mode 100644 index 0000000..41f471d --- /dev/null +++ b/.gitea/workflows/update-profile.yml @@ -0,0 +1,69 @@ +name: update-profile + +on: + schedule: + - cron: "47 23 * * *" + workflow_dispatch: + push: + branches: [main] + paths: + - "profile.json" + - "scripts/**" + - "Makefile" + - ".gitea/workflows/update-profile.yml" + +permissions: + contents: write + +env: + GITEA_API: src.panahifar.ir/api/v1 + BOT_NAME: nagini + BOT_EMAIL: noreply@src.panahifar.ir + +jobs: + update: + runs-on: linux-amd64 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + + - name: Preflight (tools and Gitea API) + run: | + set -eu + for tool in node git make; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "::error::$tool is missing from the job image - use the act-job:20 image (node:20-bookworm)." + exit 1 + fi + done + major="$(node -p 'process.versions.node.split(".")[0]')" + if [ "$major" -lt 18 ]; then + echo "::error::node $major is too old - scripts/generate.mjs needs node 18+ (fetch, AbortSignal.timeout)." + exit 1 + fi + if ! node -e "fetch('https://${GITEA_API}/version').then(r => process.exit(r.ok ? 0 : 1), () => process.exit(1))"; then + echo "::warning::https://${GITEA_API} is unreachable - the generator will keep the last good data." + fi + node --version + + - name: Generate README and assets + run: make generate + + - name: Validate output + run: make check + + - name: Commit and push changes + run: | + set -eu + git add README.md assets + if git diff --cached --quiet; then + echo "profile unchanged - nothing to commit" + exit 0 + fi + git -c user.name="$BOT_NAME" -c user.email="$BOT_EMAIL" \ + commit -m "chore(profile): regenerate README and assets [skip ci]" + # A push to main may land while this job runs: rebase once and retry. + if ! git push; then + git -c user.name="$BOT_NAME" -c user.email="$BOT_EMAIL" pull --rebase + git push + fi