labeler
labeler copied to clipboard
Added ability to pass in an optional PR number as a parameter
So so it can be used in a workflow that creates a PR automatically like repo-sync/pull-request
then add in labels at creation rather than having to run an additional workflow
name: Auto PR Creation
on:
push:
branches-ignore:
- master
- main
jobs:
create-pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo COMMIT_MSG=`git log -1 --pretty=%B` >> $GITHUB_ENV
- id: open-pr
uses: repo-sync/[email protected]
with:
source_branch: "" # If blank, default: triggered branch
destination_branch: "main" # If blank, default: master
pr_assignee: "${{ github.actor }}" # Comma-separated list (no spaces)
pr_label: "auto-pr" # Comma-separated list (no spaces)
pr_draft: true # Creates pull request as draft
pr_title: "${{ env.COMMIT_MSG }}"
pr_body: "${{ steps.pr-template.outputs.content }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Details
run: |
echo "URL: ${{steps.open-pr.outputs.pr_url}}"
echo "PR: ${{steps.open-pr.outputs.pr_number}}"
echo "CF: ${{steps.open-pr.outputs.has_changed_files}}"
- uses: credfeto/labeler@feature/pass-in-pull-request-or-issue
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/labeler.yml
sync-labels: true
pr-number: ${{steps.open-pr.outputs.pr_number}}
Also would fix https://github.com/actions/labeler/issues/304