Tool Updater #750
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 siliconcompiler/toolscripts/_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 venv .venv | |
source .venv/bin/activate | |
python3 -m pip install GitPython | |
git config --global user.name "SiliconCompiler Bot" | |
git config --global user.email "bot@siliconcompiler.com" | |
msg=$(python3 siliconcompiler/toolscripts/_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 siliconcompiler/toolscripts/_tools.py | |
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@v7 | |
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 |