-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates workflow to update the issue status column in a project based… (
#51) * Creates workflow to update the issue status column in a project based on PR * Rest? --------- Co-authored-by: Nick Telsan <[email protected]>
- Loading branch information
1 parent
2cc5355
commit 94bfcb1
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Update Issue Project Status From PR | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
update-issue-status: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check if PR links to an issue | ||
id: check-issue | ||
run: | | ||
ISSUE_NUMBER=$(curl -sL https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }} | jq -r '.issue_url' | awk -F'/' '{print $NF}') | ||
echo "Issue Number: $ISSUE_NUMBER" | ||
if [ "$ISSUE_NUMBER" != "null" ]; then | ||
echo "::set-output name=issue_number::$ISSUE_NUMBER" | ||
else | ||
echo "No linked issue found." | ||
exit 0 | ||
fi | ||
- name: Update Issue Project Status to "In Review" | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const issueNumber = process.env.issue_number; | ||
const projectId = 4; | ||
const columnName = "In Review"; | ||
const { data: project } = await github.rest.projects.get({ | ||
project_id: projectId | ||
}); | ||
const column = project.rest.columns.find(col => col.name === columnName); | ||
if (!column) { | ||
throw new Error(`Column "${columnName}" not found in project.`); | ||
} | ||
await github.rest.projects.moveCard({ | ||
card_id: issueNumber, | ||
position: 'top', | ||
column_id: column.id | ||
}); |