srggrs / assign-one-project-github-action

Automatically add an issue or pull request to specific GitHub Project(s) when you create and/or label them.
MIT License
169 stars 60 forks source link

Help: Cannot add project into new pull request #57

Closed zigang93 closed 3 years ago

zigang93 commented 3 years ago

I was able to add project into the issue. but not working on fork pull request. Am I doing something wrong??

P/S: my orgs repo is private and the fork repo also private

name: Auto PR/Issue Assign to Project(s)

on:
  issues:
    types: [opened, labeled]
  pull_request:
    types: [opened]

env:
  MY_GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}

jobs:
  assign_one_project:
    runs-on: ubuntu-latest
    name: Assign to One Project
    steps:
    - name: Assign NEW issues to project
      uses: srggrs/assign-one-project-github-action@1.2.0
      if: github.event.action == 'opened'
      with:
        project: 'https://github.com/orgs/example/projects/5'
        column_name: 'To Do'

    - name: Assign NEW PR to project
      uses: srggrs/assign-one-project-github-action@1.2.0
      if: |
        github.event == 'pull_request' &&
        (
          github.event.action == 'opened'
        )
      with:
        project: 'https://github.com/orgs/example/projects/5'
        column_name: 'In Progress'
srggrs commented 3 years ago

Hi! The workflow file seems ok, the only thing is to make sure that your project are set up correctly, so the To Do and In Progress columns are there, if not or the names do not match (I think it is ~case sensitive~) the action will fail.

Anyhow are you able to post some of the traceback from the action log? You can find it under the "Actions" menu, selecting a particular run of the action and then click on the particular job/action... you should end up with something like this: image

kvz commented 3 years ago

It seems to me there may be an issue here:

github.event == 'pull_request'
// versus:
github.event.action == 'opened'

I don't think github.event will be a string but rather an object

kvz commented 3 years ago

New to this, but i think you need github.event_name === 'pull_request' && github.event.action === 'opened'

srggrs commented 3 years ago

@zigang93 @kvz the new release (1.2.1) should fix this! let me know if not! Fixed by #62