|
| 1 | +name: Update JSON data submodule |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [json-data-updated] |
| 6 | + workflow_dispatch: {} |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + issues: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + update: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v7 |
| 18 | + with: |
| 19 | + submodules: recursive |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Update submodule to latest |
| 23 | + id: update |
| 24 | + run: | |
| 25 | + git submodule update --remote --merge src/Helldivers-2-Models/json |
| 26 | + if git diff --quiet; then |
| 27 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 28 | + else |
| 29 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 30 | + fi |
| 31 | +
|
| 32 | + - name: Setup .NET |
| 33 | + if: steps.update.outputs.changed == 'true' |
| 34 | + uses: actions/setup-dotnet@v5 |
| 35 | + with: |
| 36 | + dotnet-version: '10.0.x' # match whatever your Directory.Build.props/global.json targets |
| 37 | + |
| 38 | + - name: Build and test |
| 39 | + if: steps.update.outputs.changed == 'true' |
| 40 | + id: build |
| 41 | + continue-on-error: true |
| 42 | + run: | |
| 43 | + dotnet restore Helldivers-2.sln |
| 44 | + dotnet build Helldivers-2.sln --no-restore --configuration Release |
| 45 | + dotnet test Helldivers-2.sln --no-build --configuration Release |
| 46 | +
|
| 47 | + - name: Open PR if build succeeded |
| 48 | + if: steps.update.outputs.changed == 'true' && steps.build.outcome == 'success' |
| 49 | + uses: peter-evans/create-pull-request@v8 |
| 50 | + with: |
| 51 | + commit-message: "chore: update JSON data submodule" |
| 52 | + title: "chore: update JSON data submodule" |
| 53 | + body: | |
| 54 | + Automated update of `src/Helldivers-2-Models/json` to the latest commit on `master`. |
| 55 | + Build and tests passed. |
| 56 | + branch: auto/update-json-submodule |
| 57 | + delete-branch: true |
| 58 | + |
| 59 | + - name: Open issue if build failed |
| 60 | + if: steps.update.outputs.changed == 'true' && steps.build.outcome == 'failure' |
| 61 | + uses: actions/github-script@v9 |
| 62 | + with: |
| 63 | + script: | |
| 64 | + await github.rest.issues.create({ |
| 65 | + owner: context.repo.owner, |
| 66 | + repo: context.repo.repo, |
| 67 | + title: "Build failure after JSON submodule auto-update", |
| 68 | + body: `The automated submodule update to \`src/Helldivers-2-Models/json\` broke the build.\n\nWorkflow run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, |
| 69 | + labels: ["automated", "build-failure"] |
| 70 | + }) |
0 commit comments