push
This commit is contained in:
parent
7a63deaa79
commit
a68dc72639
@ -2,7 +2,7 @@ name: Update CI/CD Pipeline
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '39 * * * *'
|
- cron: '44 * * * *' # Runs the pipeline at the 39th minute of every hour
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
@ -14,6 +14,40 @@ jobs:
|
|||||||
- name: Cache Cargo dependencies
|
- name: Cache Cargo dependencies
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Update
|
- name: Run Update Script
|
||||||
run: ./update_laws.sh
|
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"
|
||||||
|
else
|
||||||
|
echo "No changes detected."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Push changes if any
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
|
git push origin update-branch
|
||||||
|
else
|
||||||
|
echo "No changes to push."
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
if [ -n "$(git log origin/main..HEAD)" ]; then
|
||||||
|
curl -X POST "https://gitea.example.com/api/v1/repos/{owner}/{repo}/pulls" \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-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
|
||||||
|
Loading…
Reference in New Issue
Block a user