Skip to content

Commit

Permalink
Creates workflow to update the issue status column in a project based… (
Browse files Browse the repository at this point in the history
#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
shascher and nick-telsan authored Dec 6, 2023
1 parent 2cc5355 commit 94bfcb1
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/update-pr-issue-status.yml
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
});

0 comments on commit 94bfcb1

Please sign in to comment.