Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we add option to add label on the PR? #71

Closed
vincentwongso opened this issue May 4, 2021 · 5 comments
Closed

Can we add option to add label on the PR? #71

vincentwongso opened this issue May 4, 2021 · 5 comments

Comments

@vincentwongso
Copy link

I think this will be very useful when creating PR and we want to label them as release, regression, testing, etc.

@vsoch
Copy link
Owner

vsoch commented May 4, 2021

The idea of GitHub actions is to be modular - so why not just use https://github.com/actions-ecosystem/action-add-labels?

@vincentwongso
Copy link
Author

Ahh perfect, thank you for that.

@falconmick
Copy link

falconmick commented Jun 24, 2021

@vsoch is it at all possible that we could get an example? Very fresh to GHA, in a perfect world I would love it if somhow I could chain the label add as the second job/step(?) inside the yml action file I made that creates my PR's... To take this even one step further, I had planned on using this with pascalgn/automerge-action so that when my main branch receives a push, it automatically creates a PR into a branch in which my depndabot commits go (which runs my checks) and then merges that PR provided there were no issues right away. This way whenever dependabot runs, it gets the latest and greatest codebase, but when I accept the dependabot version bumps I can stage them all together basically allowing me to make one big dependabot PR

If it helps, you can see the repo here: https://github.com/falconmick/blog

@vsoch
Copy link
Owner

vsoch commented Jun 24, 2021

I haven't tested this, but you'd want to define another step that uses outputs to direct the label to the PR.

name: Pull Request on Branch Push
on:
  # change your trigger to be what is appropriate for you here
  pull_request: []
jobs:
  auto-pull-request:
    name: PullRequestAction
    runs-on: ubuntu-latest
    steps:
      - name: pull-request-action
        id: pull_request
        uses: vsoch/pull-request-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH_PREFIX: "update/"
          PULL_REQUEST_BRANCH: "master"
          PULL_REQUEST_REVIEWERS: vsoch
      - name: Test outputs
        env:
          pull_request_number_output: ${{ steps.pull_request.outputs.pull_request_number }}
          pull_request_url_output: ${{ steps.pull_request.outputs.pull_request_url }}
        run: |
          echo "Pull request number from output: ${pull_request_number_output}"
          echo "Pull request url from output: ${pull_request_url_output}"
          echo "Pull request number from environment: ${PULL_REQUEST_NUMBER}"
          echo "Pull request url from environment: ${PULL_REQUEST_URL}"
          echo "Another way to specify from output ${{ steps.pull_request.outputs.pull_request_number }}"
      - name: Add labels
        uses: actions-ecosystem/action-add-labels@v1
        with:
          number: ${{ steps.pull_request.outputs.pull_request_number }}
          labels: bug

And the "test outputs" is just there to do exactly that - you can remove when it's working for you.

@falconmick
Copy link

Awesome I’ll give this a go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants