name: Assign Custom Properties

# This workflow assigns custom property values to repositories using the
# `set_properties.sh` script and a Personal Access Token stored in a
# repository or organisation secret.  The workflow can be triggered
# manually via the GitHub Actions UI.

'on':
  workflow_dispatch:
    # Allows the workflow to be triggered on demand.

jobs:
  assign-properties:
    runs-on: ubuntu-latest
    env:
      # Replace `PERSONAL_ACCESS_TOKEN` with the name of the secret that
      # stores your PAT.  This environment variable will be used by
      # `set_properties.sh` to authenticate API requests.
      GITHUB_TOKEN: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Install dependencies (jq, curl)
        run: |
          sudo apt-get update
          sudo apt-get install -y jq curl

      - name: Make scripts executable
        run: |
          chmod +x set_properties.sh
          chmod +x load_env.sh

      - name: Run property assignment
        run: |
          # Load token from environment; if GITHUB_TOKEN is unset or empty
          # in this workflow, `set_properties.sh` will prompt for input.
          ./set_properties.sh