-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from jhudsl/cansavvy/comprehensive-preview
Add downloadable comprehensive preview
- Loading branch information
Showing
3 changed files
with
28 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "[email protected]" | ||
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 "[email protected]" | ||
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") | ||
echo "zip_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 }}) | ||
:eyes: Quick [preview of website here](${{ steps.build-components.outputs.website_link }}) \* | ||
:microscope: Comprehensive [download of the website here](${{ steps.build-components.outputs.zip_link }}) | ||
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ | ||
\* 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata |