File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
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
+ ` ` `
You can’t perform that action at this time.
0 commit comments