|
| 1 | +# |
| 2 | +# This workflow adds a label to the issue involved on event when is pinned |
| 3 | +# and removes it when unpinned. |
| 4 | +# |
| 5 | +# It also is enhanced with `stale.yml` workflow: pinned issues never stales |
| 6 | +# because that label is declared as part of it `exempt-issue-labels` |
| 7 | +# input parameter. |
| 8 | +# |
| 9 | +name: Issues pinner management |
| 10 | + |
| 11 | +on: |
| 12 | + issues: |
| 13 | + types: |
| 14 | + - "pinned" |
| 15 | + - "unpinned" |
| 16 | + |
| 17 | +permissions: |
| 18 | + # no checkouts/branching needed |
| 19 | + contents: none |
| 20 | + # needed by "action-add-labels / action-remove-labels" to CRUD labels |
| 21 | + issues: write |
| 22 | + |
| 23 | +# This allows a subsequently queued workflow run to interrupt/wait for previous runs |
| 24 | +concurrency: |
| 25 | + group: '${{ github.workflow }} @ ${{ github.event.issue.number || github.run_id }}' |
| 26 | + cancel-in-progress: false # true: interrupt, false = wait for |
| 27 | + |
| 28 | +jobs: |
| 29 | + |
| 30 | + labeler: |
| 31 | + name: Pushpin labeler |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + |
| 35 | + - name: Add pushpin label on pinning an issue |
| 36 | + id: if-pinned |
| 37 | + if: github.event.action == 'pinned' |
| 38 | + uses: actions-ecosystem/action-add-labels@v1 |
| 39 | + with: |
| 40 | + repo: ${{ github.repository }} |
| 41 | + number: ${{ github.event.issue.number }} |
| 42 | + labels: | |
| 43 | + :pushpin: pinned |
| 44 | +
|
| 45 | + - name: Remove pushpin label on unpinning an issue |
| 46 | + id: if-unpinned |
| 47 | + if: github.event.action == 'unpinned' |
| 48 | + uses: actions-ecosystem/action-remove-labels@v1 |
| 49 | + with: |
| 50 | + repo: ${{ github.repository }} |
| 51 | + number: ${{ github.event.issue.number }} |
| 52 | + labels: | |
| 53 | + :pushpin: pinned |
| 54 | +
|
| 55 | + - name: GitHub reporter |
| 56 | + # run even previous steps fails |
| 57 | + if: always() |
| 58 | + run: | |
| 59 | + echo "$INPUT_SUMMARY" >> $GITHUB_STEP_SUMMARY; |
| 60 | + env: |
| 61 | + INPUT_SUMMARY: ${{ format('Issue [\#{2}]({0}/{1}/issues/{2}) should be `{3}`.', |
| 62 | + github.server_url, github.repository, |
| 63 | + github.event.issue.number, |
| 64 | + github.event.action) }} |
0 commit comments