|
| 1 | +name: 'Upload CWL conformance badges' |
| 2 | +author: 'Tomoya Tanjo' |
| 3 | +description: 'Upload CWL conformance badges' |
| 4 | +inputs: |
| 5 | + cwlVersion: |
| 6 | + description: 'CWL version' |
| 7 | + required: true |
| 8 | + runner-name: |
| 9 | + description: 'name of CWL runner' |
| 10 | + required: true |
| 11 | + badgedir: |
| 12 | + description: 'full path to the directory that stores conformance badges' |
| 13 | + required: true |
| 14 | + repository: |
| 15 | + description: 'repository (in the form of `owner/repo`) to store badges' |
| 16 | + required: true |
| 17 | + upload-default-branch: |
| 18 | + description: 'whether uploading the result of HEAD in the default branch' |
| 19 | + required: false |
| 20 | + default: false |
| 21 | + token: |
| 22 | + description: 'token to commit the repository specified in the `repository` field' |
| 23 | + required: true |
| 24 | +runs: |
| 25 | + using: 'composite' |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v2 |
| 28 | + with: |
| 29 | + repository: ${{ inputs.repository }} |
| 30 | + path: conformance |
| 31 | + token: ${{ inputs.token }} |
| 32 | + - name: Save badges |
| 33 | + working-directory: conformance |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + conformance_dir=$runner/cwl_$cwlVersion |
| 37 | +
|
| 38 | + mkdir -p $conformance_dir |
| 39 | + commit=$(echo $GITHUB_SHA | cut -b -6) |
| 40 | + printf '{ "subject": "commit", "status": "%s", "color": "blue" }' $commit > $badgedir/commit.json |
| 41 | +
|
| 42 | + git config user.name "$runner bot" |
| 43 | + git config user.email "${runner}[email protected]" |
| 44 | +
|
| 45 | + if [ "${{ inputs.upload-default-branch }}" = "true" ]; then |
| 46 | + default_dir=${conformance_dir}/${runner}_${default_branch} |
| 47 | + rm -rf $default_dir |
| 48 | + cp -r $badgedir $default_dir |
| 49 | + git add $default_dir |
| 50 | + fi |
| 51 | +
|
| 52 | + if [ "$has_tag" = "true" ]; then |
| 53 | + latest_dir=${conformance_dir}/${runner}_latest |
| 54 | + tag_dir=${conformance_dir}/${runner}_${tag} |
| 55 | +
|
| 56 | + rm -rf $latest_di $tag_dir |
| 57 | + printf '{ "subject": "release", "status": "%s", "color": "blue" }' ${tag} > $badgedir/version.json |
| 58 | + cp -r $badgedir $latest_dir |
| 59 | + cp -r $badgedir $tag_dir |
| 60 | + git add $latest_dir $tag_dir |
| 61 | + fi |
| 62 | +
|
| 63 | + git diff-index --quiet HEAD || git commit -m "Conformance test of $runner for CWL ${cwlVersion}" -m " Commit: ${GITHUB_SHA}" |
| 64 | +
|
| 65 | + if [ "$has_tag" = "true" ]; then |
| 66 | + git tag -a "${tag}" -m "${runner} ${tag}" |
| 67 | + fi |
| 68 | +
|
| 69 | + git push --quiet |
| 70 | + git push --quiet --tags |
| 71 | + env: |
| 72 | + cwlVersion: ${{ inputs.cwlVersion }} |
| 73 | + has_tag: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 74 | + tag: ${{ github.ref_name }} |
| 75 | + badgedir: ${{ inputs.badgedir }} |
| 76 | + runner: ${{ inputs.runner-name }} |
| 77 | + default_branch: ${{ github.event.repository.default_branch }} |
0 commit comments