Skip to content

Commit 58f27c2

Browse files
James Stone TIL sync botJonas Andersen
James Stone TIL sync bot
authored and
Jonas Andersen
committed
Tue 10 Dec 2024 20:20:37 +07
1 parent efc6651 commit 58f27c2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# To push back to a repo in a github action
2+
3+
I wanted to have a GitHub Action step push back to the repo it is running in.
4+
5+
For that you need the `write` permission. which can be added like so:
6+
7+
```yaml
8+
permissions:
9+
contents: write
10+
```
11+
12+
from: [git - Push to origin from GitHub action - Stack Overflow](https://stackoverflow.com/a/58393457)
13+
14+
eg in: [add write permission · jamesmstone/chess@d0a3250 · GitHub](https://github.com/jamesmstone/chess/commit/d0a3250e8cdafa56fa549a7d5513cd0b170a83c8)
15+
16+
17+
```yaml
18+
name: Push commit
19+
on: push
20+
permissions:
21+
contents: write
22+
jobs:
23+
report:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Create report file
28+
run: date +%s > report.txt
29+
- name: Commit report
30+
run: |
31+
git config --global user.name 'Your Name'
32+
git config --global user.email '[email protected]'
33+
git commit -am "Automated report"
34+
git push
35+
```

0 commit comments

Comments
 (0)