From 94bfcb1ae8dc2bf70311af2855efd007c3070065 Mon Sep 17 00:00:00 2001 From: Steven Hascher <30932943+shascher@users.noreply.github.com> Date: Wed, 6 Dec 2023 09:36:36 -0500 Subject: [PATCH] =?UTF-8?q?Creates=20workflow=20to=20update=20the=20issue?= =?UTF-8?q?=20status=20column=20in=20a=20project=20based=E2=80=A6=20(#51)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Creates workflow to update the issue status column in a project based on PR * Rest? --------- Co-authored-by: Nick Telsan --- .github/workflows/update-pr-issue-status.yml | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/update-pr-issue-status.yml diff --git a/.github/workflows/update-pr-issue-status.yml b/.github/workflows/update-pr-issue-status.yml new file mode 100644 index 000000000..103ff8da7 --- /dev/null +++ b/.github/workflows/update-pr-issue-status.yml @@ -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 + });