Skip to content

Commit c62063b

Browse files
authored
Merge pull request #1531 from Anselmoo/fix/weekly-update-branch
fix: 💚 Set branch as env variable
2 parents f2e8c2a + 5938fb5 commit c62063b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

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

33
on:
44
schedule:
5+
- cron: '* * * * *' # Runs every time for testing purposes
56
# - cron: '0 0 * * 0' # Runs every Sunday at midnight
6-
- cron: '0 * * * *' # Runs every hour for testing purposes
77

88
jobs:
99
update-dependencies:
@@ -26,11 +26,15 @@ jobs:
2626
curl -sSL https://install.python-poetry.org | python3 -
2727
export PATH="$HOME/.local/bin:$PATH"
2828
29+
- name: Set date variable
30+
id: date
31+
run: echo "DATE=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
32+
2933
- name: Create new branch
3034
run: |
3135
git config --global user.name 'github-actions[bot]'
3236
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
33-
git checkout -b update-dependencies-$(date +%Y%m%d%H%M)
37+
git checkout -b update-dependencies-${{ env.DATE }}
3438
3539
- name: Install dependencies
3640
run: poetry install
@@ -43,32 +47,32 @@ jobs:
4347
git add poetry.lock
4448
if git diff-index --quiet HEAD; then
4549
echo "No changes detected, creating an empty commit."
46-
git commit --allow-empty -m "chore(deps): :arrows_counterclockwise: no updates for $(date +%Y%m%d%H%M)"
50+
git commit --allow-empty -m "chore(deps): :arrows_counterclockwise: no updates for ${{ env.DATE }}"
4751
else
4852
echo "Changes detected, creating a commit with update log."
4953
if [ -f poetry-update.log ]; then
5054
update_log=$(cat poetry-update.log)
5155
else
5256
update_log="No update log available."
5357
fi
54-
git commit -m "$(echo -e "chore(deps): :arrows_counterclockwise: update dependencies $(date +%Y%m%d%H%M)\n\n$update_log")"
58+
git commit -m "$(echo -e "chore(deps): :arrows_counterclockwise: update dependencies ${{ env.DATE }}\n\n$update_log")"
5559
fi
5660
5761
- name: Push changes
5862
run: |
59-
git push -f origin update-dependencies-$(date +%Y%m%d%H%M)
63+
git push -f origin update-dependencies-${{ env.DATE }}
6064
6165
- name: Create Pull Request via gh
6266
run: |
63-
gh pr create --title "chore(deps): :arrows_counterclockwise: update dependencies $(date +%Y%m%d%H%M)" \
67+
gh pr create --title "chore(deps): :arrows_counterclockwise: update dependencies ${{ env.DATE }}" \
6468
--body "This is an auto-generated pull request to update dependencies in poetry.lock." \
6569
--base main \
66-
--head update-dependencies-$(date +%Y%m%d%H%M)
70+
--head update-dependencies-${{ env.DATE }}
6771
env:
6872
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6973

7074
- name: Merge Pull Request via gh
7175
run: |
72-
gh pr merge update-dependencies-$(date +%Y%m%d%H%M) --merge --auto
76+
gh pr merge update-dependencies-${{ env.DATE }} --merge --auto
7377
env:
7478
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)