Sync with template v19 #598
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Synchronizes the repo's labels with a local or centralized `labels.yml` file. | |
| name: Sync Labels | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| on: | |
| push: | |
| paths: [ | |
| '.github/workflows/sync-labels.yml', | |
| '.github/labels.yml' | |
| ] | |
| schedule: | |
| # At 00:00 UTC every Sunday. | |
| - cron: '0 0 * * 0' | |
| workflow_dispatch: | |
| inputs: | |
| allow_custom: | |
| type: boolean | |
| description: Allow Custom Labels | |
| required: true | |
| default: true | |
| jobs: | |
| sync-labels: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the repository under $GITHUB_WORKSPACE, so the workflow can access it. | |
| # https://github.com/actions/checkout | |
| - name: Checkout sources | |
| uses: actions/checkout@v6 | |
| # Copy the local labels.yml if it exists, else fetch from remote. | |
| - name: Prepare labels.yml | |
| run: | | |
| if [ -f ".github/labels.yml" ]; then | |
| echo "Using local labels.yml file" | |
| cp .github/labels.yml ./labels.yml | |
| else | |
| echo "Local labels.yml file not found, fetching from remote" | |
| curl -sL "https://raw.githubusercontent.com/TerminalMC/.github/HEAD/.github/labels.yml" -o ./labels.yml | |
| fi | |
| - name: Convert to JSON | |
| run: yq -o=json ./labels.yml > ./labels.json | |
| # Run the JS script. | |
| # https://github.com/actions/github-script | |
| - name: Run script sync-labels | |
| uses: actions/github-script@v9 | |
| env: | |
| ALLOW_CUSTOM: ${{ github.event.inputs.allow_custom || 'true' }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const path = require('path') | |
| const script = require( | |
| path.join(process.env.GITHUB_WORKSPACE, '.github/workflows/scripts/sync-labels.js') | |
| ) | |
| await script({ github, context, core }) |