forked from ankidroid/Anki-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (50 loc) · 1.8 KB
/
update_js_libs.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
name: Update JS Library
on:
workflow_dispatch:
jobs:
update_js_libs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Update js libs'
id: vars
run: |
# create a new branch and checkout on local
git branch update-js-libs
git checkout update-js-libs
# make executable
chmod +x ./tools/update-js-libs.sh
./tools/update-js-libs.sh
# commit changes
git config --global user.name github-actions
git config --global user.email [email protected]
git add .
git commit -am "updated mathjax and jquery"
git push --set-upstream origin update-js-libs -f
# get installed jquery and mathjax version
cd ~/tmp/anki
jquery_ver=$(npm list jquery | grep -Po "jquery@(\d+\.)+\d+" | sort -u)
mathjax_ver=$(npm list mathjax | grep -Po "mathjax@(\d+\.)+\d+")
# setting an output parameter
echo ::set-output name=jquery_ver::"$jquery_ver"
echo ::set-output name=mathjax_ver::"$mathjax_ver"
- name: 'Create pull request'
uses: actions/github-script@v7
with:
script: |
try {
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: 'update-js-libs',
base: 'main',
title: 'Update jquery and mathjax',
body: "### Updated\n ${{ steps.vars.outputs.jquery_ver }} \n ${{ steps.vars.outputs.mathjax_ver }}"
});
} catch(err) {
if (err.status === 422) {
console.log("PR already exists.")
} else {
throw err;
}
}