Skip to content

Update Submodules

Update Submodules #3

name: Update Submodules
on:
schedule:
- cron: '0 0 * * *' # runs every day at midnight UTC
workflow_dispatch: # manual trigger
jobs:
update-submodules:
runs-on: ubuntu-latest
steps:
- name: Checkout repository (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Update submodules
run: |
git submodule update --remote
git add -A
- name: Check if there are changes
id: changes
run: |
if git diff --cached --quiet; then
echo "No changes."
echo "changed=false" >> $GITHUB_ENV
else
echo "Submodules updated."
echo "changed=true" >> $GITHUB_ENV
fi
- name: Install NuGet CLI
if: env.changed == 'true'
run: |
sudo apt install -y nuget
- name: Download NuGet packages
if: env.changed == 'true'
run: |
nuget install libClang.runtime.linux-x64 -OutputDirectory ${{ github.workspace }}/nuget-packages
nuget install libClangSharp.runtime.linux-x64 -OutputDirectory ${{ github.workspace }}/nuget-packages
- name: Extract specific files
if: env.changed == 'true'
run: |
# Create the bin directory to extract the file to
mkdir -p ${{ github.workspace }}/nuget-packages/bin
# Use wildcard to match any file, for example, *.dll
unzip -o "${{ github.workspace }}/nuget-packages/*.runtime.linux-x64*/runtimes/linux-x64/native/*.so" -d ${{ github.workspace }}/nuget-packages/bin
- name: Make files executable
if: env.changed == 'true'
run: chmod +x ${{ github.workspace }}/nuget-packages/bin/*.so
- name: Add to system path
if: env.changed == 'true'
run: |
echo "${{ github.workspace }}/nuget-packages/bin" >> $GITHUB_ENV
- name: Setup .NET
if: env.changed == 'true'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Run generator
if: env.changed == 'true'
run: |
bash ./generate.bat
git add -A
- name: Check if it can build
if: env.changed == 'true'
run: dotnet build
- name: Commit and push changes
if: env.changed == 'true'
run: |
BRANCH_NAME="update-submodules-$(date +%Y%m%d%H%M%S)"
git checkout -b $BRANCH_NAME
git commit -m "Update submodules"
git push origin $BRANCH_NAME
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
- name: Create Pull Request
if: env.changed == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.branch_name }}
title: "Update Git submodules"
body: |
This PR updates the Git submodules to their latest commits.
- Auto-generated by GitHub Actions