risp/.gitea/workflows/update.yml
philipp 6fe3c2498a
Some checks failed
CI/CD Pipeline / test (push) Failing after 1m0s
Update CI/CD Pipeline / update (push) Successful in 1m16s
push
2024-10-17 19:09:19 +02:00

50 lines
1.5 KiB
YAML

name: Update CI/CD Pipeline
on:
schedule:
- cron: '10 * * * *' # Runs the pipeline at the 39th minute of every hour
env:
GITEATOKEN: ${{ secrets.GITEATOKEN }}
jobs:
update:
runs-on: ubuntu-latest
container: git.hofer.link/ruderverein-donau-linz/rowing-ci:20240215
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."
git checkout -b update-branch
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: |
echo "https://git.hofer.link/api/v1/repos/philipp/risp/pulls"
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."}'
else
echo "No changes to create a pull request."
fi