Skip to content
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

🔄 Synced file(s) with jhudsl/OTTR_Template_Website #54

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/delete-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

# Check out current repository
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:

steps:
- name: checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Verify Dockerfiles changed?
uses: tj-actions/verify-changed-files@v8.8
uses: tj-actions/verify-changed-files@v17
id: verify-changed-files
with:
files: |
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/file-automatic-issues.yml
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
59 changes: 35 additions & 24 deletions .github/workflows/pull_request.yml
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:
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand 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 }}
Expand All @@ -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 }}
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/render-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ on:
- '**.Rmd'
- styles.css
- _site.yml
- subdir_html/*.Rmd
- resources/images/*.png
- resources/images/favicon.ico
- site_libs/*

jobs:
yaml-check:
name: Load user automation choices
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Use the yaml-env-action action.
- name: Load environment from YAML
Expand All @@ -43,11 +41,11 @@ jobs:
runs-on: ubuntu-latest
container:
image: ${{needs.yaml-check.outputs.rendering_docker_image}}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# get the full repo
fetch-depth: 0
Expand All @@ -72,11 +70,14 @@ jobs:
exit 1

# Commit the rendered site files - html files and site_libs files
# The git reset step will remove any other files created in this workflow, such as API keys
- name: Commit rendered site files
run: |
git config --system --add safe.directory $GITHUB_WORKSPACE
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
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'
git add --force docs/*
git commit -m 'Render site' || echo "No changes to commit"
git reset --hard HEAD
git pull --rebase --allow-unrelated-histories --strategy-option=ours
git push origin main || echo "No changes to push"
6 changes: 6 additions & 0 deletions config_automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ spell-check: yes
style-code: yes
# Test build the docker image if any docker-relevant files have been changed
docker-test: no
# Should URLs be tested periodically?
url-check-periodically: yes

##### Renderings run upon merge to main branch #####
# Rendering each platform's content
render-bookdown: yes
render-leanpub: yes
render-coursera: no

## Automate the creation of Book.txt file? TRUE/FALSE?
## This is only relevant if render-leanpub is yes, otherwise it will be ignored
make-book-txt: TRUE

# What docker image should be used for rendering?
# The default is jhudsl/base_ottr:main
rendering-docker-image: 'jhudsl/base_ottr:main'
Loading