-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #583 from maxim-belkin/better-syncing
Template workflow: smarter syncing with the styles repo
- Loading branch information
Showing
1 changed file
with
41 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ jobs: | |
lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git] | ||
os: [ubuntu-20.04, macos-latest, windows-latest] | ||
experimental: [false] | ||
remote-theme: [false] | ||
include: | ||
- os: ubuntu-20.04 | ||
os-name: Linux | ||
|
@@ -34,7 +33,6 @@ jobs: | |
experimental: true | ||
os: ubuntu-20.04 | ||
os-name: Linux | ||
remote-theme: true | ||
- lesson: carpentries/lesson-example | ||
lesson-name: (CP) Lesson Example | ||
experimental: false | ||
|
@@ -76,26 +74,54 @@ jobs: | |
path: lesson | ||
fetch-depth: 0 | ||
|
||
- name: Determine the proper reference to use | ||
id: styles-ref | ||
- name: Sync lesson with carpentries/styles | ||
working-directory: lesson | ||
run: | | ||
if [[ -n "${{ github.event.pull_request.number }}" ]]; then | ||
echo "::set-output name=ref::refs/pull/${{ github.event.pull_request.number }}/head" | ||
echo "::group::Fetch Styles" | ||
if [[ -n "${{ github.event.pull_request.number }}" ]] | ||
then | ||
ref="refs/pull/${{ github.event.pull_request.number }}/head" | ||
else | ||
echo "::set-output name=ref::gh-pages" | ||
ref="gh-pages" | ||
fi | ||
- name: Sync lesson with carpentries/styles | ||
if: ${{ ! matrix.remote-theme }} | ||
working-directory: lesson | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "The Carpentries Bot" | ||
git remote add styles https://github.com/carpentries/styles.git | ||
git config --local remote.styles.tagOpt --no-tags | ||
git fetch styles ${{ steps.styles-ref.outputs.ref }}:styles-ref | ||
git merge -s recursive -Xtheirs --no-commit styles-ref | ||
git commit -m "Sync lesson with carpentries/styles" | ||
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 | ||
|