|
| 1 | +# This file is maintained in https://github.com/davorpatech/meta/ |
| 2 | +name: Synchronize repo labels |
| 3 | + |
| 4 | +on: |
| 5 | + push: # when push this files to branches.... |
| 6 | + branches: |
| 7 | + - 'main' |
| 8 | + paths: |
| 9 | + - '.github/labels.yml' # - definition file |
| 10 | + - '.github/workflows/sync-labels.yml' # - this workflow |
| 11 | + pull_request: # when pull over this files to branches... |
| 12 | + branches: |
| 13 | + - 'main' |
| 14 | + paths: |
| 15 | + - '.github/labels.yml' # - definition file |
| 16 | + - '.github/workflows/sync-labels.yml' # - this workflow |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + dry-run: |
| 20 | + type: boolean |
| 21 | + description: 'If enabled, changes will not be applied' |
| 22 | + required: true |
| 23 | + default: true |
| 24 | + skip-delete: |
| 25 | + type: boolean |
| 26 | + description: 'If enabled, labels will not be deleted if not found in YAML file' |
| 27 | + required: true |
| 28 | + default: true |
| 29 | + |
| 30 | +permissions: |
| 31 | + # needed for checkout code |
| 32 | + contents: read |
| 33 | +# |
| 34 | +# Note about permissions in "crazy-max/ghaction-github-labeler"... |
| 35 | +# - for list/read labels we need "issues: read". Use in conjunction with "dry-run=true" |
| 36 | +# - for a complete CRUD we need "issues: write" |
| 37 | +# |
| 38 | +# TODO: change scope to "labels: write" when available (see planned https://github.com/community/community/discussions/13565) |
| 39 | +# |
| 40 | + issues: write |
| 41 | + |
| 42 | +# This allows a subsequently queued workflow run to interrupt/wait for previous runs |
| 43 | +concurrency: |
| 44 | + group: '${{ github.workflow }}' |
| 45 | + cancel-in-progress: false # true = interrupt, false = wait |
| 46 | + |
| 47 | +jobs: |
| 48 | + |
| 49 | + sync: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@v3 |
| 54 | + |
| 55 | + - name: Sync (push) |
| 56 | + if: github.event_name == 'push' |
| 57 | + uses: crazy-max/ghaction-github-labeler@v4 |
| 58 | + with: |
| 59 | + yaml-file: '.github/labels.yml' |
| 60 | + dry-run: false # false = apply changes |
| 61 | + skip-delete: true # the least destructive case |
| 62 | + |
| 63 | + - name: Sync (PR test) |
| 64 | + if: github.event_name == 'pull_request' |
| 65 | + uses: crazy-max/ghaction-github-labeler@v4 |
| 66 | + with: |
| 67 | + yaml-file: '.github/labels.yml' |
| 68 | + dry-run: true # true = only test |
| 69 | + skip-delete: true # the least destructive case |
| 70 | + |
| 71 | + - name: Sync (manual) |
| 72 | + if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run == 'false' |
| 73 | + uses: crazy-max/ghaction-github-labeler@v4 |
| 74 | + with: |
| 75 | + yaml-file: '.github/labels.yml' |
| 76 | + dry-run: false # false = apply changes |
| 77 | + skip-delete: ${{ github.event.inputs.skip-delete != 'false' }} |
| 78 | + |
| 79 | + - name: Sync (manual test) |
| 80 | + if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run != 'false' |
| 81 | + uses: crazy-max/ghaction-github-labeler@v4 |
| 82 | + with: |
| 83 | + yaml-file: '.github/labels.yml' |
| 84 | + dry-run: true # true = only test |
| 85 | + skip-delete: ${{ github.event.inputs.skip-delete != 'false' }} |
0 commit comments