Skip to content

Commit

Permalink
Merge branch 'main' into pull_resource
Browse files Browse the repository at this point in the history
getting html updates from main
  • Loading branch information
carriewright11 committed Aug 2, 2023
2 parents 1e37ab0 + eb1b3e3 commit e050679
Show file tree
Hide file tree
Showing 98 changed files with 8,191 additions and 2,014 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

# Candace Savonen Apr 2022

name: Build Docker Image

on:
workflow_call:
inputs:
directory:
required: true
type: string
tag:
required: true
type: string
dockerhubpush:
description: 'Push to Dockerhub?'
required: false
default: 'false'
type: string
secrets:
GH_PAT:
required: true
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false

jobs:

build-docker:
name: Build Docker image
runs-on: ubuntu-latest

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

- name: Verify Dockerfiles changed?
uses: tj-actions/verify-changed-files@v8.8
id: verify-changed-files
with:
files: |
${{ inputs.directory }}/Dockerfile
${{ inputs.directory }}/github_package_list.tsv
- name: Login as jhudsl-robot
run: |
git config --local --add safe.directory "$GITHUB_WORKSPACE"
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
# Set up Docker build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# Setup layer cache
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Build
uses: docker/setup-buildx-action@v1

- name: Get token
run: echo ${{ secrets.GH_PAT }} > ${{ inputs.directory }}/git_token.txt

- name: Build Docker image
uses: docker/build-push-action@v4
with:
push: false
load: true
context: ${{ inputs.directory }}
file: ${{ inputs.directory }}/Dockerfile
tags: ${{ inputs.tag }}

# Login to Dockerhub
- name: Login to DockerHub
if: ${{ inputs.dockerhubpush != 'false' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Push the Docker image if set to true from a manual trigger
- name: Push Docker image if manual trigger set to true
if: ${{ inputs.dockerhubpush != 'false' }}
run: docker push ${{ inputs.tag }}
32 changes: 32 additions & 0 deletions .github/workflows/manual_dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Candace Savonen May 2022

name: Manual build of docker image

on:
workflow_dispatch:
inputs:
directory:
required: true
type: string
tag:
required: true
type: string
dockerhubpush:
description: 'Push to Dockerhub?'
required: false
default: 'false'
type: string

jobs:

build-it:
name: Build docker image on command
uses: ./.github/workflows/docker-test.yml
with:
directory: ${{github.event.inputs.directory}}
tag: ${{github.event.inputs.tag}}
dockerhubpush: ${{github.event.inputs.dockerhubpush}}
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
84 changes: 54 additions & 30 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ jobs:
needs: yaml-check
runs-on: ubuntu-latest
container:
image: jhudsl/intro_to_r:1.0
image: jhudsl/intro_to_r:1.1
if: ${{needs.yaml-check.outputs.toggle_render_preview == 'yes'}}

steps:
Expand All @@ -279,10 +279,14 @@ jobs:
repo_name='${{ github.event.repository.name }}'
git config --global --add safe.directory /__w/$repo_name/$repo_name
- name: Checkout files
# # Checks-out your repository with the token so your job can access it
- name: checkout
uses: actions/checkout@v3
with:
# get the full repo
fetch-depth: 0
# use github PAT
token: ${{ secrets.GH_PAT }}

# Set up git checkout
- name: Set up git checkout
Expand All @@ -295,15 +299,22 @@ jobs:
git checkout $branch_name
git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories
shell: bash

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37
# NOTE: `since_last_remote_commit: true` is implied by default and falls back to the previous local commit.

- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
# We want a fresh run of the renders each time - so first delete old html files
- name: Delete old *.html
run: Rscript -e "rmarkdown::clean_site(preview = FALSE)"

# TODO: add this to docker
- name: Install config package
run: Rscript -e "install.packages('config')"

# Now we want to render all the html files from the Rmd files
- name: Run render html for the main site
id: site
Expand All @@ -315,15 +326,33 @@ jobs:

# Render all module files
- name: Render html of modules
run: Rscript "scripts/render_modules.R"

run: |
Rscript --vanilla "scripts/render_modules.R" --files "${{ steps.changed-files.outputs.all_changed_files }}"
# Render the cheatsheets
- name: Render Cheatsheet pdfs
run: Rscript "scripts/render_cheatsheets.R"

run: |
Rscript --vanilla "scripts/render_cheatsheets.R" --files "${{ steps.changed-files.outputs.all_changed_files }}"
# Render resource pdfs
- name: Render Resource pdfs
run: Rscript "scripts/render_resources.R"
run: |
Rscript --vanilla "scripts/render_resources.R" --files "${{ steps.changed-files.outputs.all_changed_files }}"
# Generate list of files that need pdfs
- name: Get list of html to pdfs
run: |
Rscript --vanilla "scripts/render_html_list.R"
echo "$(cat files.txt)"
- name: Read html and pdf files
id: getfiles
run: |
echo "files=$(cat files.txt)" >> $GITHUB_OUTPUT
rm files.txt
rm cheatsheet_files.csv
rm lab_files.csv
rm lecture_files.csv
# This checks on the steps before it and makes sure that they completed.
# If the renders didn't complete we don't want to commit the file changes
Expand All @@ -342,7 +371,7 @@ jobs:
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

Expand Down Expand Up @@ -387,35 +416,30 @@ jobs:
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

# Save files for conversion to pdf
outputs:
pdffiles: "${{ steps.getfiles.outputs.files }}"


render-pdf-lectures:
name: Render pdf lecture slides
needs: render-preview
runs-on: ubuntu-latest
container:
image: jhudsl/course_template:main
image: jhudsl/intro_to_r:1.1
if: ${{needs.yaml-check.outputs.toggle_render_preview == 'yes'}}
strategy:
matrix:
modulenames:
- Intro
- RStudio
- Reproducibility
- Basic_R
- Data_Input
- Subsetting_Data_in_R
- Data_Summarization
- Data_Classes
- Data_Cleaning
- Manipulating_Data_in_R
- Esquisse_Data_Visualization
- Data_Visualization
- Factors
- Statistics
- Data_Output
- Functions
modulenames: ${{fromJson(needs.render-preview.outputs.pdffiles)}}

steps:
# Give permission to access the repo
- name: safelist repository
run: |
repo_name='${{ github.event.repository.name }}'
git config --global --add safe.directory /__w/$repo_name/$repo_name
- name: Checkout files
uses: actions/checkout@v3
with:
Expand Down
Loading

0 comments on commit e050679

Please sign in to comment.