Update Submodules #15
This file contains hidden or 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
| 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: Setup .NET | |
| if: env.changed == 'true' | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Install NuGet CLI | |
| if: env.changed == 'true' | |
| uses: nuget/setup-nuget@v2 | |
| - name: Install Mono | |
| if: env.changed == 'true' | |
| run: sudo apt install mono-complete | |
| - name: Download and Extract NuGet packages | |
| if: env.changed == 'true' | |
| run: | | |
| # Download NuGet packages | |
| nuget install libClang.runtime.linux-x64 -OutputDirectory ${{ github.workspace }}/nuget-packages | |
| nuget install libClangSharp.runtime.linux-x64 -OutputDirectory ${{ github.workspace }}/nuget-packages | |
| mkdir -p ${{ github.workspace }}/nuget-packages/bin | |
| # List the directory contents | |
| ls -R ${{ github.workspace }}/nuget-packages | |
| # Moving the libraries to the bin directory | |
| files=($(find ${{ github.workspace }}/nuget-packages -type f -name "*.so")) | |
| for file in "${files[@]}"; do | |
| echo "Moving $file" | |
| chmod +x "$file" | |
| mv "$file" ${{ github.workspace }}/nuget-packages/bin/ | |
| done | |
| # Add to system path | |
| echo "Adding to system path" | |
| echo "${{ github.workspace }}/nuget-packages/bin" >> $GITHUB_PATH | |
| - 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 | |