-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (41 loc) · 1.79 KB
/
pr-if-new-kernel.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
on:
workflow_dispatch:
schedule:
- cron: '0 5 * * *'
jobs:
update:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
actions: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: |
OUTPUT=$(python update-kernel.py)
echo $OUTPUT
echo "has-update=$OUTPUT" >> "$GITHUB_OUTPUT"
id: update
- name: create pull request
run: |
if [[ '${{ steps.update.outputs.has-update }}' ]]; then
git checkout -b update-kernel
git add prepare_source
git config --global user.name "Garden Linux Builder"
git config --global user.email "[email protected]"
git commit -am 'Update kernel ${{ steps.update.outputs.has-update }}'
git push --set-upstream origin update-kernel
UPDATE_PR_LINK=$(gh pr create --base main --head update-kernel --title 'Update kernel ${{ steps.update.outputs.has-update }}' --body "automated update" --reviewer fwilhe)
# We have to trigger our own workflow run because github does not do that when the pr is created by automation
# This also means that we don't have the nice UI integration of test runs, so we add a comment to the workflow url for tracing purposes
gh workflow run "build.yml" --ref "update-kernel"
echo wait a few seconds until the workflow has started
sleep 5
RUN_URL=$(gh run list --workflow=build.yml --limit=1 --branch=update-kernel --json=url --jq='.[0].url')
gh pr comment $UPDATE_PR_LINK --body "CI workflow created: $RUN_URL"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}