Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 13

Publishing download links in the check details instead of posting a comment

Solved! Go to Solution.

Hi, we just built a workflow to build a preview version in a pull-request, and push this build to our download server: https://github.com/deltachat/deltachat-desktop/blob/master/.github/workflows/build-preview.yml

 

Part of the workflow is that we want to provide the download links to the contributors directly. Right now we do this by posting a comment to the PR, but it's very noisy to have a comment for every commit. Instead we'd like to display the download links in the checks overview below, e.g. where it says "Details".

 

Is there a way to do this conveniently? I couldn't find anything in the documentation, neither could I find an Action or Job which does it already, there is only the one for posting comments.

12 Replies
Highlighted
Pilot Lvl 1
Message 2 of 13

Re: Publishing download links in the check details instead of posting a comment

 

You can post it to GitHubs API yourself.

 

We have som project where we do something along this (shell script):

GITHUB_API_URL="https://api.github.com/repos/${PROJECT_USERNAME}/${PROJECT_REPONAME}/statuses/${SHA1}"

STATE=success

STATUS_DATA="{\"state\": \"${STATE}\", \"description\": \"Report\", \"context\": \"My status\", \"target_url\": \"${ARTIFACT_URL}\"}"

curl --fail --silent -X POST --user ":${GITHUB_TOKEN}" "${GITHUB_API_URL}" --data "${STATUS_DATA}"

 

(ok, we do that from CircleCI but I think you should be able to do it from an action as well.

 

Highlighted
Copilot Lvl 3
Message 3 of 13

Re: Publishing download links in the check details instead of posting a comment

cool, will try it out!

Highlighted
Copilot Lvl 3
Message 4 of 13

Re: Publishing download links in the check details instead of posting a comment

Hm, I'm playing around with it, but the API doesn't seem to do anything. Neither does it give me a proper error message. Where would the message pop up?

 

Do I need to use a user with write access to the repository, or is it okay to use the Github actions bot for this? Or is there something else I did wrong?

https://github.com/deltachat/deltachat-desktop/pull/1116/files#diff-e897be051354af89d81ad484418359d5...

 

The request itself looks fine to me in the logs: https://github.com/deltachat/deltachat-desktop/pull/1116/checks?check_run_id=291090229

Highlighted
Pilot Lvl 1
Message 5 of 13

Re: Publishing download links in the check details instead of posting a comment

Weird. I think somethings wrong with SHA, but cannot figure out why.

 

Your action posts the status to the SHA c239d9ac7d5b5a47d2fc28892c55cdd226facd2c but I can't find that SHA in repos / in the PR. From the PR it looks like the SHA should be ae82c8b4a7b9f74672bf5881b0095141f1aac700.

Highlighted
Copilot Lvl 3
Message 6 of 13

Re: Publishing download links in the check details instead of posting a comment

Hm, this seems to be the merge commit which would be generated when the PR would be merged after this commit: https://github.com/deltachat/deltachat-desktop/tree/c239d9ac7d5b5a47d2fc28892c55cdd226facd2c

 

I read something in this direction in some thread. I guess I need that commit ID so the build job can be referenced correctly?

Pilot Lvl 1
Message 7 of 13

Re: Publishing download links in the check details instead of posting a comment

Could it be github.ref instaed of github.sha?

 

I had a debug dump of the github context somewhere but can't find it ...

 

Nah... It should be github.sha  ... 

 

I made a test over at https://github.com/arnested/playground/pull/4 and github.sha  corresponds to the commit in PR ... weird

Highlighted
Solution
Pilot Lvl 1
Message 8 of 13

Re: Publishing download links in the check details instead of posting a comment

Posting a status worked for me in: https://github.com/arnested/playground/pull/5

 

Still no clue on what's different in your example...

Highlighted
Copilot Lvl 3
Message 9 of 13

Re: Publishing download links in the check details instead of posting a comment

Ah, the difference is that you are using a push event, not a pull-request event. push events don't create a merge commit, but use just their own commit's SHA. PR events create a merge commit and use that SHA.

 

The best solution would probably be if the API would answer to the merge commit's SHA. Do you know where I could open an issue for that?

 

Highlighted
Copilot Lvl 3
Message 10 of 13

Re: Publishing download links in the check details instead of posting a comment

I got it! I could get the SHA from the PR event: https://github.com/deltachat/deltachat-desktop/pull/1116/files

 

Thanks so much for taking your time to debug this with me! I learned a lot.