name: License

on: # yamllint disable-line rule:truthy
  schedule:
    - cron: "0 1 1 1 *"
  workflow_dispatch:

permissions:
  contents: read

jobs:
  update-license-year:
    name: Update license year
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - name: Check out code from GitHub
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Setup app
        id: app
        uses: ./.github/actions/setup-app
        with:
          app-id: ${{ secrets.PR2D2_APP_ID }}
          private-key: ${{ secrets.PR2D2_APP_PRIVATE_KEY }}

      - name: Update license
        uses: FantasticFiasco/action-update-license-year@v3
        with:
          token: ${{ steps.app.outputs.token }}
