actions / add-to-project

Automate adding issues and pull requests to GitHub projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Input required and not supplied: github-token

Gellipapa opened this issue · comments

Hi! Can you help me?

I'm having a problem that sometimes I can't get a possible token for github actions and that's why I get this error
(Error: Input required and not supplied: github-token)

This happens when someone opens a pull request from a fork. How can I fix it to always use tokens from source repository?

In the current actions of the pull request, issue is run on open.

I searched the internet for a solution, but I didn't find any great solution because it works anyway, so I guess I need to set something in the actions.

Thanks for the answer in advance.

actions file

name: Add issue or pull request to project board

on:
  issues:
    types:
      - opened
  pull_request:
    types:
      - opened

jobs:
  add-to-project:
    name: Add issue or pull request to project
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v3
      - name: Get event creation date
        id: date
        run: |
          if [[ "${{ github.event_name }}" == "issues" ]]; then
            echo "date=${{ github.event.issue.created_at }}" >> $GITHUB_ENV
          elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
            echo "date=${{ github.event.pull_request.created_at }}" >> $GITHUB_ENV
          fi
      - name: Add to project
        uses: actions/add-to-project@v0.5.0
        with:
          project-url: https://github.com/orgs/test/projects/9
          github-token: ${{ secrets.MY_GITHUB_TOKEN }}
        id: add-project
      - name: Update project fields
        uses: titoportas/update-project-fields@v0.1.0
        with:
          project-url: https://github.com/orgs/test/projects/9
          github-token: ${{ secrets.MY_GITHUB_TOKEN }}
          item-id: ${{ steps.add-project.outputs.itemId }}
          field-keys: Date
          field-values: ${{ env.date }},

Hi! It's been a long time since I solved it but I'll write down the solution. pull_request_target should be used, if necessary you should also enter PAT(Personal Access Token) in the token key in the checkout section.

It's also important to have a secret token, because if you don't have one, you will get this error.