Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: API call in main merge #6

Merged
merged 5 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
merge_group:
pull_request:
push:
branches: [main]
# branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -20,7 +20,13 @@ jobs:
run: |
echo "github.event_name: ${{ github.event_name }}"
echo "github.event.action: ${{ github.event.action }}"


- name: Dump GitHub Context.Event
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "${GITHUB_CONTEXT}" | jq .

# Test for PR, merge queue and merge to main
get-pr:
name: Get PR number
Expand Down
14 changes: 10 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ runs:
- id: vars
shell: bash
run: |
set -eux

# Get PR number (different process for merge queue)
if [ ${{ github.event_name }} == 'pull_request' ]
then
Expand All @@ -43,7 +41,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 -sL -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?"
Expand All @@ -54,7 +60,7 @@ runs:
fi

# Validate PR number
if [ ! "${PR_NO}" =~ ^[0-9]+$ ]; then
if [[ ! "${pr}" =~ ^[0-9]+$ ]]; then
echo "PR number format incorrect: ${pr}"
exit 1
fi
Expand Down