Skip to content

Commit e22a943

Browse files
authored
Merge pull request #1511 from Anselmoo/fix/weekly-updater
fix: 💚 Refactoring `weekly-poetry-bot.yml`
2 parents f4efe5a + 3aa6aa6 commit e22a943

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

.github/workflows/weekly-poetry-bot.yml

+25-14
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Weekly Poetry Update
22

33
on:
44
schedule:
5-
# - cron: '0 0 * * 0' # Runs every Sunday at midnight
6-
- cron: '0 * * * *' # Runs every hour
5+
- cron: '0 0 * * 0' # Runs every Sunday at midnight
76

87
jobs:
98
update-dependencies:
@@ -26,37 +25,49 @@ jobs:
2625
curl -sSL https://install.python-poetry.org | python3 -
2726
export PATH="$HOME/.local/bin:$PATH"
2827
28+
- name: Create new branch
29+
run: |
30+
git config --global user.name 'github-actions[bot]'
31+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
32+
git checkout -b update-dependencies-$(date +%Y%m%d)
33+
2934
- name: Install dependencies
3035
run: poetry install
3136

3237
- name: Update dependencies
3338
run: poetry update | tee poetry-update.log
3439

35-
- name: Create new branch
40+
- name: Commit changes
3641
run: |
37-
git config --global user.name 'github-actions[bot]'
38-
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
39-
git checkout -b update-dependencies-$(date +%Y%m%d)
4042
git add poetry.lock
4143
if git diff-index --quiet HEAD; then
4244
echo "No changes detected, creating an empty commit."
4345
git commit --allow-empty -m "chore(deps): :arrows_counterclockwise: no updates for $(date +%Y%m%d)"
4446
else
45-
echo "Changes detected, creating a commit with poetry-update log."
46-
update_log=$(cat poetry-update.log)
47+
echo "Changes detected, creating a commit with update log."
48+
if [ -f poetry-update.log ]; then
49+
update_log=$(cat poetry-update.log)
50+
else
51+
update_log="No update log available."
52+
fi
4753
git commit -m "$(echo -e "chore(deps): :arrows_counterclockwise: update dependencies $(date +%Y%m%d)\n\n$update_log")"
4854
fi
4955
56+
- name: Push changes
57+
run: |
58+
git push -f origin update-dependencies-$(date +%Y%m%d)
59+
5060
- name: Create Pull Request via gh
51-
run: >-
52-
gh pr create --title "chore(deps): :arrows_counterclockwise: update dependencies $(date +%Y%m%d)"
53-
--body "This is an auto-generated pull request to update dependencies in poetry.lock."
54-
--base main
61+
run: |
62+
gh pr create --title "chore(deps): :arrows_counterclockwise: update dependencies $(date +%Y%m%d)" \
63+
--body "This is an auto-generated pull request to update dependencies in poetry.lock." \
64+
--base main \
5565
--head update-dependencies-$(date +%Y%m%d)
5666
env:
57-
GITHUB_TOKEN: ${{ secrets.auto_changelog }}
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
5869
- name: Set Auto PR
5970
run: |
6071
gh pr merge update-dependencies-$(date +%Y%m%d) --auto --rebase
6172
env:
62-
GITHUB_TOKEN: ${{ secrets.auto_changelog }}
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)