-
Notifications
You must be signed in to change notification settings - Fork 251
95 lines (83 loc) · 2.91 KB
/
parse-submission.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Parse Submission
on:
push:
branches:
- main
jobs:
check-commit-message:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check.outputs.skip }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{ secrets.RBD_GITHUB_TOKEN }}
- name: Check commit message
id: check
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
if [[ "$COMMIT_MESSAGE" == "Update repository stats" || "$COMMIT_MESSAGE" == "Update app info" ]]; then
echo "skip=true" >> $GITHUB_ENV
echo "::set-output name=skip::true"
else
echo "skip=false" >> $GITHUB_ENV
echo "::set-output name=skip::false"
fi
update-app-info:
if: needs.check-commit-message.outputs.skip == 'false'
runs-on: ubuntu-latest
needs: check-commit-message
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{ secrets.RBD_GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: cd shipixen && npm install
- name: Run update script
run: cd shipixen/scripts && node parse-app-info.js
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Update app info"
git pull --rebase
git push
env:
GITHUB_TOKEN: ${{ secrets.RBD_GITHUB_TOKEN }}
update-stats:
if: needs.check-commit-message.outputs.skip == 'false'
runs-on: ubuntu-latest
needs: update-app-info
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{ secrets.RBD_GITHUB_TOKEN }}
- name: Get repository stats
id: get_stats
run: |
REPO_INFO=$(curl -s https://api.github.com/repos/${{ github.repository }})
STARS=$(echo $REPO_INFO | jq .stargazers_count)
FORKS=$(echo $REPO_INFO | jq .forks_count)
echo "stars=$STARS" >> $GITHUB_ENV
echo "forks=$FORKS" >> $GITHUB_ENV
- name: Write stats to stats.js
run: |
echo "module.exports = { stars: ${{ env.stars }}, forks: ${{ env.forks }} };" > shipixen/data/stats.js
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.RBD_GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add shipixen/data/stats.js
git commit -m 'Update repository stats'
git pull --rebase
git push https://x-access-token:${{ secrets.RBD_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git