Skip to content

Commit a940619

Browse files
author
Jonas Andersen
committed
re add file
1 parent bf27f8f commit a940619

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
```
36+
37+
38+
It it discussed on the github blog: [GitHub Actions: Control permissions for GITHUB\_TOKEN - GitHub Changelog](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/)
39+
40+
41+
and here is the docs: [Automatic token authentication - GitHub Docs](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token)

0 commit comments

Comments
 (0)