|
37 | 37 | env:
|
38 | 38 | GITHUB_CONTEXT: ${{ toJson(github) }}
|
39 | 39 | run: echo "$GITHUB_CONTEXT"
|
| 40 | + |
| 41 | + - name: Update issue state |
| 42 | + env: |
| 43 | + ISSUE_ID: {{ github.event.issue.number }} |
| 44 | + NEW_STATE: {{ github.event.action }} |
| 45 | + run: >- |
| 46 | + awk \ |
| 47 | + -v issue_id="$ISSUE_ID" \ |
| 48 | + -v new_state="$NEW_STATE" \ |
| 49 | + 'BEGIN { FS="\t"; OFS="\t" } { if ($2 == issue_id && $3 != new_state) { $3=new_state }; print $0 }' \ |
| 50 | + todos-on-github.tsv \ |
| 51 | + > todos-on-github.tsv.new |
| 52 | +
|
| 53 | + - name: Check for the changes |
| 54 | + run: | |
| 55 | + if ! diff --brief todos-on-github.tsv todos-on-github.tsv.new >/dev/null; then |
| 56 | + echo 'todos-on-github.tsv has been modified' |
| 57 | + mv todos-on-github.tsv.new todos-on-github.tsv |
| 58 | + PUZZLES_MAPPING_MODIFIED=yes |
| 59 | + else |
| 60 | + PUZZLES_MAPPING_MODIFIED=no |
| 61 | + fi |
| 62 | +
|
| 63 | + # Make variable available for the next steps |
| 64 | + echo "PUZZLES_MAPPING_MODIFIED=$PUZZLES_MAPPING_MODIFIED" | tee -a "$GITHUB_ENV" |
| 65 | +
|
| 66 | + - name: Commit updated mapping |
| 67 | + if: env.PUZZLES_MAPPING_MODIFIED == 'yes' |
| 68 | + env: |
| 69 | + GIT_AUTHOR_NAME: 'GitHub Action' |
| 70 | + GIT_COMMITTER_NAME: 'GitHub Action' |
| 71 | + GIT_AUTHOR_EMAIL: '[email protected]' |
| 72 | + GIT_COMMITTER_EMAIL: '[email protected]' |
| 73 | + run: | |
| 74 | + git add todos-on-github.tsv |
| 75 | + git commit todos-on-github.tsv -m 'chore: update issues state' |
| 76 | + git push |
| 77 | +
|
| 78 | + - name: Cleanup |
| 79 | + if: always() |
| 80 | + run: | |
| 81 | + [ ! -f todos-on-github.tsv.new ] || rm -fv todos-on-github.tsv.new |
0 commit comments