diff --git a/.github/workflows/osgeo4w.yml b/.github/workflows/osgeo4w.yml index deccc879a0c6..86f39535fd40 100644 --- a/.github/workflows/osgeo4w.yml +++ b/.github/workflows/osgeo4w.yml @@ -104,7 +104,8 @@ jobs: %GITHUB_WORKSPACE%\scripts\ccache -sv - - uses: actions/upload-artifact@v4 + - id: upload + uses: actions/upload-artifact@v4 with: name: ${{ matrix.pkg }} path: x86_64/ @@ -112,7 +113,47 @@ jobs: - name: Save build cache for push only uses: actions/cache/save@v4 - if: ${{ github.event_name == 'push' }} + if: github.event_name == 'push' with: path: ccache key: build-ccache-osgeo4w-${{ matrix.pkg }}-${{ github.ref_name }}-${{ github.run_id }} + + - run: npm install xml-js + if: github.event_name == 'pull_request' + - name: 'Post artifact download link and test results as comment on PR' + uses: actions/github-script@v7 + if: github.event_name == 'pull_request' + with: + script: | + let fs = require('fs'); + let tag = String(fs.readFileSync("src/${{ matrix.pkg }}/osgeo4w/build/Testing/TAG")).split("\r\n")[0] + let buildid = require('xml-js').xml2js(fs.readFileSync("src/${{ matrix.pkg }}/osgeo4w/build/Testing/" + tag + "/Done.xml"), {compact:true, ignoreDeclaration:true})['Done']['buildId']['_text'] + + const prComments = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + const PREFIX = "## OSGeo4W package ${{ matrix.pkg }} ready!"; + let body = PREFIX + "\n\n" + "Package of this PR is available for testing [here](${{ steps.upload.output.artifact-url }})."; + body += "\n\n*(Built from commit " + context.sha + ")*\n"; + body += "\n\n*(Test results are [here](https://cdash.orfeo-toolbox.org/build/" + buildId + "))*"; + + const winBuildComment = prComments.data?.find(c => c.body.startsWith(PREFIX)); + if (!!winBuildComment) { + // update the existing comment + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: winBuildComment.id, + body: body + }); + } else { + // submit a new comment + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: body + }); + }