risp/.gitea/workflows/update.yml
Philipp Hofer 2617e73499
All checks were successful
CI/CD Pipeline / test (push) Successful in 2m12s
Update CI/CD Pipeline / update (push) Successful in 17m23s
use new rust
2025-01-10 00:06:52 +01:00

56 lines
1.7 KiB
YAML

name: Update CI/CD Pipeline
on:
schedule:
- cron: '@daily'
env:
GITEATOKEN: ${{ secrets.GITEATOKEN }}
jobs:
update:
runs-on: ubuntu-latest
container: git.hofer.link/philipp/ci-images:rust-2025-01-03
steps:
- uses: actions/checkout@v3
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Run Update Script
run: ./update_laws.sh
- name: Check for changes and create branch if necessary
run: |
git config --global user.email "ci-bot@example.com"
git config --global user.name "CI Bot"
if [ -n "$(git status --porcelain)" ]; then
echo "Changes detected. Committing and preparing to push."
if git ls-remote --exit-code --heads origin update-branch; then
echo "Branch 'update-branch' exists. Checking it out."
git fetch
git checkout remote/update-branch
else
echo "Branch 'update-branch' does not exist. Creating it."
git checkout -b update-branch
fi
git add .
git commit -m "Automated update of laws"
git push origin update-branch
else
echo "No changes detected."
exit 0
fi
- name: Create Pull Request
if: success()
run: |
if [ -n "$(git log origin/main..HEAD)" ]; then
curl -X POST "https://git.hofer.link/api/v1/repos/philipp/risp/pulls" \
-H "Authorization: token $GITEATOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"Update laws","head":"update-branch","base":"main","body":"Automated update of laws.", "assignee": "philipp"}'
else
echo "No changes to create a pull request."
fi