-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add downloadable comprehensive preview #61
Changes from 12 commits
4f6b015
8fd8ba9
1c3a5e0
bd018c3
e1a40f4
2d15340
8c8e535
973e303
ca04d46
1754955
85ca988
b74cbd3
2fc90bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,10 @@ jobs: | |
# Make the branch fresh | ||
- name: Make the branch fresh | ||
run: | | ||
git config --local user.email "itcrtrainingnetwork@gmail.com" | ||
git config --local user.name "jhudsl-robot" | ||
git config --global --add safe.directory $GITHUB_WORKSPACE | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
|
||
branch_name='preview-${{ github.event.pull_request.number }}' | ||
echo branch doesnt exist | ||
git checkout -b $branch_name || echo branch exists | ||
|
@@ -83,9 +85,9 @@ jobs: | |
# Set up git checkout | ||
- name: Set up git checkout | ||
run: | | ||
git config --system --add safe.directory $GITHUB_WORKSPACE | ||
git config --local user.email "itcrtrainingnetwork@gmail.com" | ||
git config --local user.name "jhudsl-robot" | ||
git config --global --add safe.directory $GITHUB_WORKSPACE | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
|
||
branch_name='preview-${{ github.event.pull_request.number }}' | ||
git fetch --all | ||
|
@@ -110,13 +112,16 @@ jobs: | |
echo site status ${{steps.site.outcome}} | ||
exit 1 | ||
|
||
- name: Website preview for download | ||
run: zip website-preview.zip docs/* -r | ||
|
||
# Commit the rendered website files | ||
- name: Commit rendered website files to preview branch | ||
id: commit | ||
run: | | ||
branch_name='preview-${{ github.event.pull_request.number }}' | ||
git diff origin/main -- '*.html' >/dev/null && changes=true || changes=false | ||
echo ::set-output name=changes::$changes | ||
echo "changes=$changes" >> $GITHUB_OUTPUT | ||
git add . --force | ||
git commit -m 'Render preview' || echo "No changes to commit" | ||
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours | ||
|
@@ -136,9 +141,11 @@ jobs: | |
run: | | ||
course_name=$(head -n 1 _website.yml | cut -d'"' -f 2| tr " " "-") | ||
website_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html") | ||
echo ::set-output name=website_link::$website_link | ||
echo ::set-output name=time::$(date +'%Y-%m-%d') | ||
echo ::set-output name=commit_id::$GITHUB_SHA | ||
docs_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we name this something more descriptive, like "zip_file" ? docs_link makes it sound like its gonna take you to documentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also break this chunk up into "# Store variables" and "# Print to log" for readability? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do! On both accounts! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh actually the "echo to log" can't really be separated the |
||
echo "docs_link=$docs_link" >> $GITHUB_OUTPUT | ||
echo "website_link=$website_link" >> $GITHUB_OUTPUT | ||
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT | ||
echo ${{steps.commit.outputs.changes}} | ||
|
||
- name: Create or update comment | ||
|
@@ -148,9 +155,12 @@ jobs: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
Re-rendered previews from the latest commit: See [preview of website here](${{ steps.build-components.outputs.website_link }}) | ||
|
||
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ | ||
:eyes: Quick [preview of website here](${{ steps.build-components.outputs.website_link }}) \* | ||
:microscope: Comprehensive [download of the website here](${{ steps.build-components.outputs.docs_link }}) | ||
|
||
\* note not all html features will be properly displayed in the "quick preview" but it will give you a rough idea. | ||
|
||
_Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_ | ||
edit-mode: replace | ||
|
||
- name: No comment if no changes | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata |
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.
appears not to be used. Did you mean to echo it to the log?
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.
Deleted!