Skip to content

Commit d6b79c4

Browse files
committed
Updated generator workflows to be able to push
1 parent e3dcb62 commit d6b79c4

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.github/workflows/generate-types-autopr.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
- cron: '0 3 * * 1' # Every Monday at 03:00 UTC
66
workflow_dispatch:
77

8+
permissions:
9+
contents: write # Needed for PR creation and branch pushes
10+
811
jobs:
912
generate-and-pr:
1013
runs-on: ubuntu-latest
@@ -31,7 +34,7 @@ jobs:
3134
run: |
3235
git config --global user.name "github-actions[bot]"
3336
git config --global user.email "github-actions[bot]@users.noreply.github.com"
34-
git add Types/**/*.g.cs
37+
git add Types/**/*.g.cs || true
3538
if git diff --cached --quiet; then
3639
echo "no_changes=true" >> $GITHUB_OUTPUT
3740
else

.github/workflows/pr-generator.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
generate-and-commit:
1212
runs-on: ubuntu-latest
1313

14+
permissions:
15+
contents: write # Needed to allow push with GITHUB_TOKEN
16+
1417
steps:
1518
- name: Checkout PR branch
1619
uses: actions/checkout@v4
@@ -44,15 +47,24 @@ jobs:
4447
run: |
4548
git config --global user.name "github-actions[bot]"
4649
git config --global user.email "github-actions[bot]@users.noreply.github.com"
47-
git add Types/**/*.g.cs
50+
git add Types/**/*.g.cs || true
4851
if git diff --cached --quiet; then
4952
echo "no_changes=true" >> $GITHUB_OUTPUT
5053
else
5154
echo "no_changes=false" >> $GITHUB_OUTPUT
5255
fi
5356
57+
- name: Set up authentication for push
58+
if: steps.last-commit.outputs.author != 'github-actions[bot]' && steps.git-check.outputs.no_changes == 'false'
59+
run: |
60+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
5464
- name: Commit and push changes to PR branch
5565
if: steps.last-commit.outputs.author != 'github-actions[bot]' && steps.git-check.outputs.no_changes == 'false'
5666
run: |
5767
git commit -m "chore(types): update generated types (PR auto-update)"
58-
git push
68+
git push
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)