-
Notifications
You must be signed in to change notification settings - Fork 476
72 lines (63 loc) · 2.07 KB
/
update-readme.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Update README.md
on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 0"
permissions:
actions: read
checks: read
contents: write
deployments: none
issues: read
packages: none
pull-requests: write
repository-projects: none
security-events: none
statuses: none
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest --ignore-platform-reqs
- name: update readme
run: php misc/updateReadme.php
- name: Prepare git config
run: |
cat <<- EOF > $HOME/.netrc
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "[email protected]"
git config --global user.name "$GITHUB_ACTOR"
- name: push changes & create PR
run: |
changes=($( git diff --numstat ))
if [[ ${changes[0]} -gt 1 ]]
then
cd $GITHUB_WORKSPACE
git push origin --delete updatereadme || true
git branch -D updatereadme || true
git checkout -b updatereadme
git add README.md
git commit -m "update README.md"
git push --set-upstream origin updatereadme
curl \
--request POST \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"title":"Update README.md",
"body":"updates detections in README.md",
"head":"updatereadme",
"base":"master"
}' \
--url https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls
fi
shell: bash