Skip to content

Commit 1a0cbaf

Browse files
author
ynbot
committed
[Automated] Update assign_pr_to_project caller workflow
1 parent acfccd5 commit 1a0cbaf

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

.github/workflows/assign_pr_to_project.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,46 @@ on:
33
workflow_dispatch:
44
inputs:
55
pr_number:
6-
type: number
6+
type: string
77
description: "Run workflow for this PR number"
88
required: true
99
project_id:
10-
type: number
10+
type: string
1111
description: "Github Project Number"
1212
required: true
13-
default: 16
13+
default: "16"
1414
pull_request:
1515
types:
1616
- opened
1717

18+
env:
19+
GH_TOKEN: ${{ github.token }}
20+
1821
jobs:
22+
get-pr-repo:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
pr_repo_name: ${{ steps.get-repo-name.outputs.repo_name || github.event.pull_request.head.repo.full_name }}
26+
27+
# INFO `github.event.pull_request.head.repo.full_name` is not available on manual triggered (dispatched) runs
28+
steps:
29+
- name: Get PR repo name
30+
if: ${{ github.event_name == 'workflow_dispatch' }}
31+
id: get-repo-name
32+
run: |
33+
repo_name=$(gh pr view ${{ inputs.pr_number }} --json headRepository,headRepositoryOwner --repo ${{ github.repository }} | jq -r '.headRepositoryOwner.login + "/" + .headRepository.name')
34+
echo "repo_name=$repo_name" >> $GITHUB_OUTPUT
35+
1936
auto-assign-pr:
20-
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
37+
needs:
38+
- get-pr-repo
39+
if: ${{ needs.get-pr-repo.outputs.pr_repo_name == github.repository }}
2140
uses: ynput/ops-repo-automation/.github/workflows/pr_to_project.yml@main
2241
with:
2342
repo: "${{ github.repository }}"
24-
project_id: "${{ inputs.project_id }}"
25-
pull_request_number: "${{ github.event.pull_request.number || inputs.pr_number }}"
43+
project_id: ${{ inputs.project_id != '' && fromJSON(inputs.project_id) || 16 }}
44+
pull_request_number: ${{ github.event.pull_request.number || fromJSON(inputs.pr_number) }}
2645
secrets:
27-
token: ${{ secrets.YNPUT_BOT_TOKEN }}
46+
# INFO fallback to default `github.token` is required for PRs from forks
47+
# INFO organization secrets won't be available to forks
48+
token: ${{ secrets.YNPUT_BOT_TOKEN || github.token}}

0 commit comments

Comments
 (0)