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

Fix bug related to /transfer-rendered-files.yml #117

Merged
merged 12 commits into from
Feb 16, 2024
26 changes: 15 additions & 11 deletions .github/workflows/transfer-rendered-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,23 @@ jobs:
if: ${{needs.yaml-check.outputs.toggle_coursera == 'yes' || needs.yaml-check.outputs.toggle_leanpub == 'yes'}}

steps:
- name: checkout
uses: actions/checkout@v4
with:
path: bookdown
token: ${{ secrets.GH_PAT }}

- 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")
results=$(Rscript --vanilla bookdown/scripts/git_repo_check.R --repo "$GITHUB_REPOSITORY" --git_pat "$GH_PAT")
echo $QUIZ_REPO exists: $results

echo "git_results=$results" >> $GITHUB_OUTPUT
Expand All @@ -67,6 +68,7 @@ jobs:
if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }}
uses: actions/checkout@v4
with:
path: quizzes
repository: ${{ steps.git_repo_check.outputs.leanpub_repo }}
token: ${{ secrets.GH_PAT }}

Expand All @@ -76,17 +78,19 @@ jobs:
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
# Copy over images folder (from bookdown to quizzes repo)
mkdir -p quizzes/resources/chapt_screen_images
cp bookdown/resources/chapt_screen_images/* quizzes/resources/chapt_screen_images

# Copy over _bookdown.yml (from bookdown to quizzes repo)
cp bookdown/_bookdown.yml quizzes/_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:
path: quizzes # Must create the PR in the Quizzes Repo
token: ${{ secrets.GH_PAT }}
commit-message: Copy files from Bookdown repository
signoff: false
Expand Down
Loading