-
-
Notifications
You must be signed in to change notification settings - Fork 3
104 lines (86 loc) · 3.13 KB
/
update_submodules.yml
File metadata and controls
104 lines (86 loc) · 3.13 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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'
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
# Unzip the packages
mkdir -p ${{ github.workspace }}/nuget-packages/bin
files=($(find ${{ github.workspace }}/nuget-packages -maxdepth 1 -type f))
for file in "${files[@]}"; do
echo "Unzipping $file"
unzip "$file" '*.so' -o -j -d ${{ github.workspace }}/nuget-packages/bin
done
# Make files executable
chmod +x ${{ github.workspace }}/nuget-packages/bin/*.so
# Add to system path
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