-
Notifications
You must be signed in to change notification settings - Fork 4
46 lines (42 loc) · 1.47 KB
/
auto-update-dependencies.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
name: auto-update-dependencies
on:
push:
branches:
- develop
permissions:
contents: read
env:
BRANCH_NAME: ${{ github.head_ref }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
jobs:
run:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm install axios --no-save
- name: Run dependency update script
run: node scripts/generateDependenciesList.js
- name: Do not commit yarn file
run: |
git checkout -- yarn.lock
- name: Auto-commit updated dependencies file
run: |
echo "Committing docs/DEPENDENCIES.md changes..."
FILE="docs/DEPENDENCIES.md"
CONTENT=$(base64 -w 0 "$FILE")
SHA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/contents/$FILE?ref=$BRANCH_NAME" | jq -r .sha)
if [ "$SHA" == "null" ]; then
SHA=""
fi
curl -s -X PUT -H "Authorization: token $GITHUB_TOKEN" \
-d "{\"message\":\"Commit updated dependencies file [auto-generated]\", \"content\":\"$CONTENT\", \"branch\":\"$BRANCH_NAME\", \"sha\":\"$SHA\"}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/contents/$FILE"