11name : Validate sync
22
3- # Grant permissions to create issues & PR comments
43permissions :
54 contents : read
6- issues : write
75 pull-requests : write
86
97on :
108 push :
119 branches : ["master"]
1210 pull_request :
13- branches : [ "master" ]
11+ branches : ["master"]
1412 schedule :
1513 - cron : ' 0 0 * * *'
1614
@@ -19,30 +17,27 @@ jobs:
1917 runs-on : ubuntu-latest
2018
2119 steps :
22- - name : Checkout code
23- uses : actions/checkout@v3
20+ - uses : actions/checkout@v4
2421
2522 - name : Setup .NET
26- uses : actions/setup-dotnet@v3
23+ uses : actions/setup-dotnet@v4
2724 with :
2825 dotnet-version : ' 9.0.x'
2926
27+ - name : Download JSON submodule
28+ run : git submodule update --init ./src/Helldivers-2-Models/json
29+
3030 - name : Run sync and capture logs
3131 id : run_sync
3232 shell : bash
33- # continue-on-error so we can handle failures in later steps
3433 continue-on-error : true
3534 run : |
3635 set -o pipefail
36+ dotnet build
3737 dotnet run --project ./src/Helldivers-2-CI/Helldivers-2-CI.csproj 2>&1 | tee sync.log
38- EXIT_CODE=${PIPESTATUS[0]}
39- # expose exit code and full log as step outputs
40- echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
41- echo "log<<EOF" >> $GITHUB_OUTPUT
42- cat sync.log >> $GITHUB_OUTPUT
43- echo "EOF" >> $GITHUB_OUTPUT
4438
4539 - name : Upload artifacts
40+ if : always()
4641 uses : actions/upload-artifact@v4
4742 with :
4843 name : sync-artifacts
@@ -51,34 +46,35 @@ jobs:
5146 v2/*.json
5247 sync.log
5348
54- - name : Create an issue on failure (schedule or push to master)
55- if : steps.run_sync.outputs.exit_code != '0' && github.event_name != 'pull_request'
56- uses : peter-evans/create-pull-request@v7
57- with :
58- title : ' [Sync Validation] Failure on ${{ github.ref_name }}'
59- body : |
60- The sync validation run (ID ${{ github.run_id }}) failed with exit code `${{ steps.run_sync.outputs.exit_code }}`.
61-
62- **Error log**:
63- ```text
64- ${{ steps.run_sync.outputs.log }}
65- ```
66-
67- **Artifacts** (JSON output + log) are available here:
68- ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts
49+ - name : Capture error log
50+ id : sync_log
51+ if : ${{ steps.run_sync.outcome == 'failure' && github.event_name == 'pull_request' }}
52+ run : |
53+ # open a multi-line output called "log"
54+ echo "log<<EOF" >> $GITHUB_OUTPUT
55+ cat sync.log >> $GITHUB_OUTPUT
56+ echo "EOF" >> $GITHUB_OUTPUT
6957
7058 - name : Comment on PR on failure
71- if : steps.run_sync.outputs.exit_code != '0 ' && github.event_name == 'pull_request'
59+ if : ${{ steps.run_sync.outcome == 'failure ' && github.event_name == 'pull_request' }}
7260 uses : peter-evans/create-or-update-comment@v4
7361 with :
62+ token : ${{ secrets.GITHUB_TOKEN }}
7463 issue-number : ${{ github.event.pull_request.number }}
7564 body : |
76- The sync validation run (ID ${{ github.run_id }}) failed with exit code `${{ steps.run_sync.outputs.exit_code }}`.
65+ ⚠️ **Sync validation failed** (run #${{ github.run_number }} exited with ${{ steps.run_sync.outcome }})
66+
67+ <details>
68+ <summary>Error log</summary>
69+
70+ ` ` ` text
71+ ${{ steps.sync_log.outputs.log }}
72+ ` ` `
73+ </details>
7774
78- **Error log**:
79- ```text
80- ${{ steps.run_sync.outputs.log }}
81- ```
75+ **Artifacts** (JSON + log) here:
76+ ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
8277
83- **Artifacts** (JSON output + log) are available here:
84- ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts
78+ - name : Fail job on error
79+ if : ${{ steps.run_sync.outcome == 'failure' }}
80+ run : exit 1
0 commit comments