-
Notifications
You must be signed in to change notification settings - Fork 83
88 lines (75 loc) · 2.51 KB
/
tool_updater.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
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
name: 'Tool Updater'
jobs:
get_tools:
name: 'Get updatable tools'
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
outputs:
tools: ${{ steps.tools.outputs.tools }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Tools
id: tools
run: |
echo "tools=$(python3 setup/_tools.py --json_tools)" >> $GITHUB_OUTPUT
update_tool:
needs: get_tools
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.get_tools.outputs.tools) }}
name: 'Update tool'
runs-on: ubuntu-latest
steps:
- name: Check if draft exists
id: check
run: |
draft=$(gh pr list --repo siliconcompiler/siliconcompiler --head bot/${{ matrix.tool }}-update --json isDraft --jq .[0].isDraft)
if [[ "$draft" = "true" ]] ; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Checkout repository
if: steps.check.outputs.skip != 'true'
uses: actions/checkout@v4
with:
ref: main
- name: Update tool
if: steps.check.outputs.skip != 'true'
id: update
run: |
python3 -m pip install GitPython
git config --global user.name "SiliconCompiler Bot"
git config --global user.email "bot@siliconcompiler.com"
msg=$(python3 setup/_tools.py --bump_commit --tool ${{ matrix.tool }})
echo $msg
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "msg<<$EOF" >> $GITHUB_OUTPUT
echo "$msg" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
git add setup/_tools.json
git commit -m "$msg" || true
- name: Create Pull Request
if: steps.update.outputs.msg != '' && steps.check.outputs.skip != 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.BOT_TOKEN }}
title: "[SC-BOT] Update ${{ matrix.tool }}"
author: "SiliconCompiler Bot <bot@siliconcompiler.com>"
committer: "SiliconCompiler Bot <bot@siliconcompiler.com>"
body: |
${{ steps.update.outputs.msg }}
commit-message: |
Update ${{ matrix.tool }}
branch: bot/${{ matrix.tool }}-update
base: main
delete-branch: true