-
Notifications
You must be signed in to change notification settings - Fork 36
85 lines (78 loc) · 2.69 KB
/
Copy pathupdate.yml
File metadata and controls
85 lines (78 loc) · 2.69 KB
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
name: Update
run-name: Update
on:
workflow_dispatch:
schedule:
- cron: "0 8,20 * * *"
jobs:
Update-Dependencies:
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Update dependencies
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
git config user.name 'GitHub Actions'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git pull
git branch -D bot 2>/dev/null || true
git checkout -b bot
has_updates=0
git submodule update --remote
if [ -n "$(git diff libfastjson)" ]; then
has_updates=1
commitid=$(cd libfastjson && git rev-parse --short HEAD)
git add libfastjson
git commit -m "chore: Update submodule libfastjson to $commitid"
fi
if [ -n "$(git diff libpatchelf/patchelf)" ]; then
has_updates=1
commitid=$(cd libpatchelf/patchelf && git rev-parse --short HEAD)
git add libpatchelf/patchelf
git commit -m "chore: Update submodule patchelf to $commitid"
fi
bump_msg=$(scripts/update-deps.py)
if [ -n "$(git diff scripts/deps.sh)" ]; then
has_updates=1
git add scripts/deps.sh version.txt
git commit -m "chore: $bump_msg"
fi
if [ "$has_updates" -ne 0 ]; then
echo "has_updates=1" >> $GITHUB_ENV
git push --force -u origin bot
fi
- name: Open PR
env:
GITHUB_TOKEN: ${{ github.token }}
if: ${{ env.has_updates }}
run: |
pr_url=$(gh pr create --head bot --base master --title "[BOT] Update dependencies" --body "Update dependencies")
echo "pr_url=$pr_url" >> $GITHUB_ENV
- name: Lable PR
env:
GITHUB_TOKEN: ${{ secrets.pr_token }}
if: ${{ env.pr_url }}
run: |
gh pr edit '${{ env.pr_url }}' --add-label bot
- name: Create issue on failure
if: failure()
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
message="[BOT] Job ${{github.job}} is failling"
owner="$(gh repo view --json 'owner' --jq '.owner.login')"
len=$(gh issue list --json 'id' --jq length --state 'open' \
--search "$message")
if [ "$len" = '0' ]; then
gh issue create --assignee "${owner}" \
--title "$message" \
--body "$message"
fi