Skip to content

Update

Update #4

Workflow file for this run

name: Update
on:
workflow_dispatch:
permissions:
contents: write
actions: write
pull-requests: write
defaults:
run:
shell: bash
jobs:
update:
runs-on: ubuntu-latest
env:
UPDATED_MODULES: ""
TRIGGER_TIME: ""
steps:
# With Github App identity, it can trigger the workflow while the default Github Token can't.
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
# Following configuration is for Github App identity
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
- name: Update Submodule
run: |
git submodule update --remote --recursive --merge
- name: Check for Changes
run: |
if git diff --quiet; then
echo "No changes detected, cancelling the workflow."
curl -fsSL -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel
exit 0
else
echo "Changes detected, continue."
fi
UPDATED_MODULES="$(git diff --name-only 2>/dev/null | sed 's/^/- /g')"
TRIGGER_TIME="$(date +"%Y-%m-%d %H:%M:%S")"
echo "UPDATED_MODULES=$UPDATED_MODULES" >> $GITHUB_ENV
echo "TRIGGER_TIME=$TRIGGER_TIME" >> $GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
title: "Update submodules"
committer: ${{ vars.APP_COMMITTER_NAME }} <${{ vars.APP_COMMITTER_EMAIL }}>
commit-message: "Update submodules"
body: |
**Updated modules:**
---
The following submodule(s) have been updated:
${{ env.UPDATED_MODULES }}
Please manually merge this PR if everything goes ok with the updated submodules.
---
**Workflow:** [${{ github.workflow }} #${{ github.run_number }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
**Triggered at:** ${{ env.TRIGGER_TIME }}
---
This PR was generated by an action.
branch: "actions/patch"
token: ${{ steps.app-token.outputs.token }}