generated from jhudsl/OTTR_Template
-
Notifications
You must be signed in to change notification settings - Fork 2
112 lines (94 loc) · 4.14 KB
/
transfer-rendered-files.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# This code was adapted from code written by Josh Shapiro
# for the Childhood Cancer Data Lab, an initiative of Alexs Lemonade Stand Foundation.
# https://github.com/AlexsLemonade/exercise-notebook-answers
# Adapted for this jhudsl repository by Candace Savonen Apr 2021
name: Copy over from main template to _Quizzes repo
on:
workflow_dispatch:
workflow_run:
workflows: [ "Render all output courses" ]
branches: [ main, staging ]
types:
- completed
jobs:
yaml-check:
name: Load user automation choices
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Use the yaml-env-action action.
- name: Load environment from YAML
uses: doughepi/[email protected]
with:
files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence.
outputs:
toggle_coursera: "${{ env.RENDER_COURSERA }}"
toggle_leanpub: "${{ env.RENDER_LEANPUB }}"
file-quizzes-pr:
name: File _Quizzes Transfer PR
runs-on: ubuntu-latest
container:
image: jhudsl/ottrpal:main
needs: [yaml-check]
if: ${{needs.yaml-check.outputs.toggle_coursera == 'yes' || needs.yaml-check.outputs.toggle_leanpub == 'yes'}}
steps:
- name: Run git repo check
id: git_repo_check
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
sudo apt-get install subversion
# What's the Quizzes repository's name?
QUIZ_REPO=$(echo ${GITHUB_REPOSITORY} | sed "s/_Bookdown/ /g" | sed "s/_Template/ /g" | awk '{print $1"_Quizzes"}')
echo $QUIZ_REPO
# Get repo check script
svn export --force https://github.com/${GITHUB_REPOSITORY}.git/branches/${GITHUB_REF#refs/heads/}/scripts/git_repo_check.R git_repo_check.R
# Run repo check script
results=$(Rscript --vanilla git_repo_check.R --repo "$GITHUB_REPOSITORY" --git_pat "$GH_PAT")
echo $QUIZ_REPO exists: $results
echo "git_results=$results" >> $GITHUB_OUTPUT
echo "leanpub_repo=$QUIZ_REPO" >> $GITHUB_OUTPUT
- name: Checkout code from Leanpub repo
if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }}
uses: actions/checkout@v3
with:
repository: ${{ steps.git_repo_check.outputs.leanpub_repo }}
token: ${{ secrets.GH_PAT }}
- name: Get files from Bookdown repo
if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }}
shell: bash
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
# Copy over images folder
svn export --force https://github.com/${GITHUB_REPOSITORY}.git/branches/${GITHUB_REF#refs/heads/}/resources/chapt_screen_images resources/chapt_screen_images
# Copy over _bookdown.yml
svn export --force https://github.com/${GITHUB_REPOSITORY}.git/branches/${GITHUB_REF#refs/heads/}/_bookdown.yml _bookdown.yml
- name: Create PR with resources files
if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }}
uses: peter-evans/create-pull-request@v3
id: cpr
with:
token: ${{ secrets.GH_PAT }}
commit-message: Copy files from Bookdown repository
signoff: false
branch: auto_copy_rendered_files
delete-branch: true
title: 'GHA: Automated transfer of ottrpal-needed files from Bookdown repository'
body: |
### Description:
This PR was initiated by transfer-rendered.yml in the Bookdown repository.
It copies over the ottrpal-needed folder (for the `bookdown_to_embed_leanpub(render = FALSE)` function
to run properly.
- resources/chapt_screen_images/*
- _bookdown.yml
labels: |
automated
reviewers: $GITHUB_ACTOR
# Write out PR info
- name: Check outputs
if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"