|
15 | 15 | lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git] |
16 | 16 | os: [ubuntu-20.04, macos-latest, windows-latest] |
17 | 17 | experimental: [false] |
18 | | - remote-theme: [false] |
19 | 18 | include: |
20 | 19 | - os: ubuntu-20.04 |
21 | 20 | os-name: Linux |
|
34 | 33 | experimental: true |
35 | 34 | os: ubuntu-20.04 |
36 | 35 | os-name: Linux |
37 | | - remote-theme: true |
38 | 36 | - lesson: carpentries/lesson-example |
39 | 37 | lesson-name: (CP) Lesson Example |
40 | 38 | experimental: false |
@@ -76,26 +74,46 @@ jobs: |
76 | 74 | path: lesson |
77 | 75 | fetch-depth: 0 |
78 | 76 |
|
79 | | - - name: Determine the proper reference to use |
80 | | - id: styles-ref |
| 77 | + - name: Sync lesson with carpentries/styles |
| 78 | + working-directory: lesson |
81 | 79 | run: | |
82 | | - if [[ -n "${{ github.event.pull_request.number }}" ]]; then |
83 | | - echo "::set-output name=ref::refs/pull/${{ github.event.pull_request.number }}/head" |
| 80 | + if [[ -n "${{ github.event.pull_request.number }}" ]] |
| 81 | + then |
| 82 | + ref="refs/pull/${{ github.event.pull_request.number }}/head" |
84 | 83 | else |
85 | | - echo "::set-output name=ref::gh-pages" |
| 84 | + ref="gh-pages" |
86 | 85 | fi |
87 | 86 |
|
88 | | - - name: Sync lesson with carpentries/styles |
89 | | - if: ${{ ! matrix.remote-theme }} |
90 | | - working-directory: lesson |
91 | | - run: | |
92 | 87 | git config --global user.email "[email protected]" |
93 | 88 | git config --global user.name "The Carpentries Bot" |
| 89 | +
|
94 | 90 | git remote add styles https://github.com/carpentries/styles.git |
95 | | - git config --local remote.styles.tagOpt --no-tags |
96 | | - git fetch styles ${{ steps.styles-ref.outputs.ref }}:styles-ref |
97 | | - git merge -s recursive -Xtheirs --no-commit styles-ref |
98 | | - git commit -m "Sync lesson with carpentries/styles" |
| 91 | + git fetch styles $ref:styles-ref |
| 92 | +
|
| 93 | + # Sync up only if necessary |
| 94 | + if [[ $(git rev-list --count HEAD..styles-ref) != 0 ]] |
| 95 | + then |
| 96 | +
|
| 97 | + # The merge command below might fail for lessons that use remote theme |
| 98 | + # https://github.com/carpentries/carpentries-theme |
| 99 | + if ! git merge -s recursive -Xtheirs --no-commit styles-ref |
| 100 | + then |
| 101 | +
|
| 102 | + # Remove "deleted by us, unmerged" files from the staging area. |
| 103 | + # these are the files that were removed from the lesson |
| 104 | + # but are still present in the carpentries/styles repo |
| 105 | + git rm $(git diff --name-only --diff-filter=DU) |
| 106 | +
|
| 107 | + # If there are still "unmerged" files, |
| 108 | + # let's raise an error and look into this more closely |
| 109 | + if [[ -n $(git diff --name-only --diff-filter=U) ]] |
| 110 | + then |
| 111 | + exit 1 |
| 112 | + fi |
| 113 | + fi |
| 114 | +
|
| 115 | + git commit -m "Sync lesson with carpentries/styles" |
| 116 | + fi |
99 | 117 |
|
100 | 118 | - name: Look for R-markdown files |
101 | 119 | id: check-rmd |
|
0 commit comments