Skip to content

Commit 3392baf

Browse files
committed
👷 Incredible actions"
1 parent 47c01ab commit 3392baf

File tree

3 files changed

+59
-21
lines changed

3 files changed

+59
-21
lines changed

.github/workflows/sync_template.yaml

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
1-
# File: .github/workflows/template-sync.yml
21
name: Template Sync
32

43
on:
5-
# cronjob trigger
64
schedule:
75
- cron: "0 0 1 * *"
8-
# manual trigger
96
workflow_dispatch:
7+
108
jobs:
119
repo-sync:
1210
runs-on: ubuntu-latest
13-
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
1411
permissions:
1512
contents: write
1613
pull-requests: write
1714
if: github.repository != 'nicebots-xyz/botkit'
1815

1916
steps:
20-
# To use this repository's private action, you must check out the repository
2117
- name: Checkout
2218
uses: actions/checkout@v4
23-
# https://github.com/actions/checkout#usage
24-
# uncomment if you use submodules within the repository
25-
# with:
26-
# submodules: true
2719

28-
- name: actions-template-sync
20+
- name: Template Sync
21+
id: template-sync
2922
uses: AndreasAugustin/actions-template-sync@v2
3023
with:
3124
github_token: ${{ secrets.GITHUB_TOKEN }}
3225
source_repo_path: nicebots-xyz/botkit
3326
upstream_branch: dev
3427
pr_commit_msg: "core: :twisted_rightwards_arrows: Merge remote template"
35-
pr_title: "core: :twisted_rightwards_arrows: Merge remote template"
28+
pr_title: "core: :twisted_rightwards_arrows: Merge remote template"
29+
30+
update-deps:
31+
needs: repo-sync
32+
if: needs.repo-sync.outputs.pr_branch
33+
uses: ./.github/workflows/update-dependencies.yml
34+
with:
35+
pr_branch: ${{ needs.repo-sync.outputs.pr_branch }}
36+
permissions:
37+
contents: write
38+
pull-requests: write
+42-10
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,71 @@
1-
name: Update Dependencies
2-
1+
name: Update dependencies
32
on:
43
schedule:
54
- cron: '0 0 * * 0' # Runs at 00:00 every Sunday
6-
workflow_dispatch: # Allows manual triggering
5+
workflow_dispatch:
6+
inputs:
7+
pr_branch:
8+
description: 'Branch to push changes to (optional)'
9+
required: false
10+
type: string
11+
workflow_call:
12+
inputs:
13+
pr_branch:
14+
description: 'Branch to push changes to'
15+
required: true
16+
type: string
717

818
jobs:
9-
update-dependencies:
19+
update-deps:
1020
runs-on: ubuntu-latest
1121
permissions:
1222
contents: write
1323
pull-requests: write
1424
steps:
1525
- uses: actions/checkout@v4
26+
1627
- name: Setup PDM
1728
uses: pdm-project/setup-pdm@v4
1829
with:
1930
cache: true
31+
2032
- name: Lock dependencies
2133
run: pdm lock
34+
2235
- name: Export requirements
2336
run: pdm run export
37+
2438
- name: Check for changes
2539
id: git-check
2640
run: |
2741
git diff --exit-code --quiet requirements.txt || echo "changed=true" >> $GITHUB_OUTPUT
28-
- name: Create Pull Request
42+
43+
- name: Handle dependency updates
2944
if: steps.git-check.outputs.changed == 'true'
3045
run: |
3146
git config user.name github-actions
3247
git config user.email [email protected]
33-
git checkout -b update-dependencies-${{ github.run_id }}
34-
git add requirements.txt pyproject.toml pdm.lock
35-
git commit -m "Update dependencies"
36-
git push origin update-dependencies-${{ github.run_id }}
37-
gh pr create --title "Update dependencies" --body "This PR updates the project dependencies. Please review the changes and merge if everything looks good." --base ${{ github.ref_name }} --head update-dependencies-${{ github.run_id }}
48+
49+
if [ -n "${{ inputs.pr_branch }}" ]; then
50+
# Push to existing branch
51+
BRANCH_NAME=$(echo ${{ inputs.pr_branch }} | cut -d'/' -f 3)
52+
git checkout $BRANCH_NAME
53+
git add requirements.txt pyproject.toml pdm.lock
54+
git commit -m "Update dependencies"
55+
git push origin $BRANCH_NAME
56+
else
57+
# Create new branch and PR
58+
NEW_BRANCH="update-dependencies-${{ github.run_id }}"
59+
git checkout -b $NEW_BRANCH
60+
git add requirements.txt pyproject.toml pdm.lock
61+
git commit -m "Update dependencies"
62+
git push origin $NEW_BRANCH
63+
64+
gh pr create \
65+
--title "Update dependencies" \
66+
--body "This PR updates the project dependencies. Please review the changes and merge if everything looks good." \
67+
--base ${{ github.ref_name }} \
68+
--head $NEW_BRANCH
69+
fi
3870
env:
3971
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.templatesyncignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.copywrite.hcl
2+
requirements.txt
3+
pdm.lock

0 commit comments

Comments
 (0)