generated from jhudsl/OTTR_Template_Website
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #54 from jhudsl/repo-sync/OTTR_Template_Website/de…
…fault 🔄 Synced file(s) with jhudsl/OTTR_Template_Website
- Loading branch information
Showing
6 changed files
with
97 additions
and
36 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
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,43 @@ | ||
# Code adapted from https://github.com/JetBrains/intellij-platform-plugin-template/blob/deb171483598ee8a5d7621154db880e87b4db4ef/.github/workflows/template-cleanup.yml | ||
# by Candace Savonen for this repository. | ||
|
||
name: Starting a Website | ||
|
||
on: | ||
push: | ||
branches: [ main, staging ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
# Run cleaning process only if workflow is triggered by not being in the Bookdown template anymore | ||
template-cleanup: | ||
name: Template Cleanup | ||
runs-on: ubuntu-latest | ||
if: github.event.repository.name != 'OTTR_Template_Website' | ||
steps: | ||
- name: checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
# Issue for what repository settings need to be set | ||
- name: New Course - Set Repository Settings | ||
uses: peter-evans/create-issue-from-file@v4 | ||
with: | ||
title: New Course - Set Repository Settings | ||
content-filepath: .github/automatic-issues/set-repo-settings.md | ||
labels: automated training issue | ||
|
||
# Issue for what needs to be edited | ||
- name: New Course - Templates to Edit | ||
uses: peter-evans/create-issue-from-file@v4 | ||
with: | ||
title: New Course - Templates to Edit | ||
content-filepath: .github/automatic-issues/templates-to-edit.md | ||
labels: automated training issue | ||
|
||
# Issue for how to enroll repo for updates | ||
- name: New Course - Template Update Enrollment | ||
uses: peter-evans/create-issue-from-file@v4 | ||
with: | ||
title: New Course - Template Update Enrollment | ||
content-filepath: .github/automatic-issues/update-enrollment.md | ||
labels: automated training issue |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Candace Savonen Dec 2021 | ||
# Updated April 2023 | ||
# Updated Aug 2024 | ||
name: Pull Request | ||
|
||
on: | ||
|
@@ -13,9 +13,10 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.GH_PAT }} | ||
|
||
# Use the yaml-env-action action. | ||
- name: Load environment from YAML | ||
|
@@ -25,17 +26,19 @@ jobs: | |
|
||
# Delete the branch if this has been run before | ||
- name: Delete branch locally and remotely | ||
run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete" | ||
run: git push --force origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete" | ||
|
||
# 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 | ||
git push --set-upstream origin $branch_name | ||
git push --force --set-upstream origin $branch_name | ||
shell: bash | ||
|
||
outputs: | ||
|
@@ -71,21 +74,21 @@ jobs: | |
needs: yaml-check | ||
runs-on: ubuntu-latest | ||
container: | ||
image: jhudsl/course_template:main | ||
image: ${{needs.yaml-check.outputs.rendering_docker_image}} | ||
if: ${{needs.yaml-check.outputs.toggle_render_preview == 'yes'}} | ||
|
||
steps: | ||
- name: Checkout files | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# 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,21 +113,24 @@ jobs: | |
echo site status ${{steps.site.outcome}} | ||
exit 1 | ||
# Commit the rendered website files | ||
- name: Commit rendered website files to preview branch | ||
- name: Website preview for download | ||
run: zip website-preview.zip docs/* -r | ||
|
||
# Commit the website files | ||
- name: Commit rendered website files | ||
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 | ||
git diff origin/main -- docs >/dev/null && changes=true || changes=false | ||
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 | ||
git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours | ||
git push --force || echo "No changes to commit" | ||
shell: bash | ||
|
||
- name: Find Comment | ||
uses: peter-evans/find-comment@v1 | ||
uses: peter-evans/find-comment@v3 | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
|
@@ -136,26 +142,31 @@ 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 | ||
if: steps.commit.outputs.changes == 'true' | ||
uses: peter-evans/create-or-update-comment@v1 | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
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 | ||
if: steps.commit.outputs.changes == 'false' | ||
uses: peter-evans/create-or-update-comment@v1 | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
|
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