From 07cd547bf40616b96913e350904965348f72f057 Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Tue, 5 Dec 2023 20:09:23 -0800 Subject: [PATCH] feat: push event (#5) --- .github/workflows/pr-open.yml | 8 +++++--- action.yml | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 29be0e6..cea6851 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -13,11 +13,13 @@ concurrency: jobs: # Dump GitHub Context.Event dump: - name: Dump GitHub Context.Event + name: Event details runs-on: ubuntu-22.04 steps: - - name: Dump GitHub Context.Event - run: echo "${{ toJson(github.event) }}" | sed -r 's/#/\\#/g' + - name: Event details + run: | + echo "github.event_name: ${{ github.event_name }}" + echo "github.event.action: ${{ github.event.action }}" # Test for PR, merge queue and merge to main get-pr: diff --git a/action.yml b/action.yml index dee257d..99acb13 100644 --- a/action.yml +++ b/action.yml @@ -34,9 +34,23 @@ runs: # Get PR number (different process for merge queue) if [ ${{ github.event_name }} == 'pull_request' ] then + echo "Event type: pull request" pr=${{ github.event.number }} - else + elif [ ${{ github.event_name }} == 'merge_group' ] + then + echo "Event type: merge queue" pr=$(echo ${{ github.event.merge_group.head_ref }} | grep -Eo "queue/main/pr-[0-9]+" | cut -d '-' -f2) + 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) + if [ -z "${pr}" ] + then + echo "No PR number found. Was this push triggered by a squashed PR merge?" + pr="" + fi + else + echo "Event type: unknown or unexpected" fi echo "Summary ---"