Skip to content

Commit

Permalink
add pr comments for packages
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed May 15, 2024
1 parent ed0d4e2 commit bfdcb80
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions .github/workflows/osgeo4w.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,56 @@ 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/
retention-days: 1

- 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
});
}

0 comments on commit bfdcb80

Please sign in to comment.