ci: regenerate the profile daily with Gitea Actions
This commit is contained in:
1 file changed
+69
@@ -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
|
||||
Reference in new issue
Block a user