From 65d1f4eec45b7d25dbd5363e854faa680f2cb7bd Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Tue, 5 Dec 2023 20:32:14 -0800 Subject: [PATCH] API call --- .github/workflows/pr-open.yml | 2 +- action.yml | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index cea6851..f23740c 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -4,7 +4,7 @@ on: merge_group: pull_request: push: - branches: [main] + # branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/action.yml b/action.yml index 99acb13..72d0550 100644 --- a/action.yml +++ b/action.yml @@ -43,7 +43,15 @@ runs: elif [ ${{ github.event_name }} == 'push' ] then echo "Event type: push" - pr=$(echo ${{ github.event.head_commit.message }} |( grep -Eo "pr-[0-9]+" || true )| cut -d '-' -f2) + # HEAD=$(git log main --oneline | head -n1 | awk '{print $1}') + HEAD=${{ github.event.after }} + pr=$(\ + curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/commits/${HEAD}/pulls \ + | jq .[0].number + ) + if [ -z "${pr}" ] then echo "No PR number found. Was this push triggered by a squashed PR merge?"