Skip to content

Commit

Permalink
Apply Zhian's suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: Zhian N. Kamvar <zkamvar@gmail.com>
  • Loading branch information
maxim-belkin and zkamvar authored Apr 23, 2021
1 parent d3f553d commit db953ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/workflows/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
- name: Sync lesson with carpentries/styles
working-directory: lesson
run: |
echo "::group::Fetch Styles"
if [[ -n "${{ github.event.pull_request.number }}" ]]
then
ref="refs/pull/${{ github.event.pull_request.number }}/head"
Expand All @@ -89,31 +90,38 @@ jobs:
git remote add styles https://github.com/carpentries/styles.git
git fetch styles $ref:styles-ref
echo "::endgroup::"
echo "::group::Synchronize Styles"
# Sync up only if necessary
if [[ $(git rev-list --count HEAD..styles-ref) != 0 ]]
then
# The merge command below might fail for lessons that use remote theme
# https://github.com/carpentries/carpentries-theme
echo "Testing merge using recursive strategy, accepting upstream changes without committing"
if ! git merge -s recursive -Xtheirs --no-commit styles-ref
then
# Remove "deleted by us, unmerged" files from the staging area.
# these are the files that were removed from the lesson
# but are still present in the carpentries/styles repo
echo "Removing previously deleted files"
git rm $(git diff --name-only --diff-filter=DU)
# If there are still "unmerged" files,
# let's raise an error and look into this more closely
if [[ -n $(git diff --name-only --diff-filter=U) ]]
then
echo "There were unmerged files in ${{ matrix.lesson-name }}:"
echo "$(git diff --compact-summary --diff-filter=U)"
exit 1
fi
fi
echo "Committing changes"
git commit -m "Sync lesson with carpentries/styles"
fi
echo "::endgroup::"
- name: Look for R-markdown files
id: check-rmd
Expand Down

0 comments on commit db953ba

Please sign in to comment.