-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci : Add github action workflow to generate documentation preview #23
base: main
Are you sure you want to change the base?
Conversation
- name: Save pull request context to artifact directory | ||
run: | | ||
echo ${{ github.event.pull_request.number }} > ./public/pr_number.txt | ||
echo ${{ github.sha }} | cut -c 1-7 > ./public/sha.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a way to extract PR number and SHA from pull request context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for PR number I use the ${{ github.event.number }}
but I guess this way is fine as well...
https://github.com/redhat-developer/mapt/blob/main/.github/workflows/build-oci.yaml#L27C49-L27C75
About the sha... I did not make it but I recall Jakub struggle a bit with it... on the e2e sample flow he moved all github context and inspect for the sha like this https://github.com/crc-org/crc/blob/6d72284a886c4978e13e4775b9b8f552e134bf18/.github/workflows/windows-qe-tpl.yml#L65
Cause if I recall it right values were a but messy as they depend on firs open for the PR or forced push...but I can not ensure may your payload value is always valid...just take a look at the code from the link...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think I should drop the SHA specific preview approach altogether? I think contributor would only be interested in the latest pushed branch preview only 🤔 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I think it's better to upload PR github context file as artifact rather than creating single files for specific attributes.
Let me update it as per your suggestion.
|
||
jobs: | ||
on-close: | ||
runs-on: ubuntu-latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor thing, I would suggest to set the version instead of latest to be sure about it ubuntu-24.04
this would apply to the other files as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I've updated all workflows to use ubuntu-24.04
- name: Save pull request context to artifact directory | ||
run: | | ||
echo ${{ github.event.pull_request.number }} > ./public/pr_number.txt | ||
echo ${{ github.sha }} | cut -c 1-7 > ./public/sha.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for PR number I use the ${{ github.event.number }}
but I guess this way is fine as well...
https://github.com/redhat-developer/mapt/blob/main/.github/workflows/build-oci.yaml#L27C49-L27C75
About the sha... I did not make it but I recall Jakub struggle a bit with it... on the e2e sample flow he moved all github context and inspect for the sha like this https://github.com/crc-org/crc/blob/6d72284a886c4978e13e4775b9b8f552e134bf18/.github/workflows/windows-qe-tpl.yml#L65
Cause if I recall it right values were a but messy as they depend on firs open for the PR or forced push...but I can not ensure may your payload value is always valid...just take a look at the code from the link...
|
||
jobs: | ||
documentation-preview: | ||
runs-on: ubuntu-latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May recall to add a condition on trigger completed + is successfully??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I had forgotten to add the condition for successful completion. I've added it.
629282f
to
a64507d
Compare
Add github action to generate documentation preview by publishing gh-pages on an external repository. This change adds four new github action workflows: - Documentation Preview Request: A workflow that would run on the pull request and generate website and upload it as a github artifact. - Documentation Preview Generator: A workflow that would get triggered on the completion of `Documentation Preview Request` workflow and it would download the uploaded artifact and deploy the content to github repository configured in secrets. - Documentation Preview Cleanup Request: A workflow that would run on pull request upon the closing event of pull request. It would save pull request number as an artifact and upload it. - Documentation Preview Cleanup: A workflow that would get triggered on the completion of `Documentation Preview Cleanup Request` workflow and it would download the uploaded artifact and update the github repository and remove the generated preview directory. Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Description
This pull request adds functionality of publishing documentation changes added in pull requests to some temporary github repository and posting the generated preview documentation via a URL.
Added GitHub action to generate documentation preview by publishing GitHub Pages on an external repository.
I've tested this workflow on my fork. You can see a demo PR here
Prerequisites
In order to changes added in this pull request to work, we need to do these things first:
Github Action workflows added:
This change adds four new github action workflows:
Documentation Preview Request
workflow and it would download the uploaded artifact and deploy the content to github repository configured in secrets.Documentation Preview Cleanup Request
workflow and it would download the uploaded artifact and update the github repository and remove the generated preview directory.