.github/workflows/pr-if-new-kernel.yml #48
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 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 }} |