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

GitHub workflow testing missing ref PR merge #1981

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
55 changes: 55 additions & 0 deletions .github/workflows/test-missing-git-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: missing-git-ref-issue
on:
workflow_dispatch:

jobs:
open-close-reopen-pr:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BRANCH: oriy/testRefMerge

steps:
- name: Checkout
uses: actions/checkout@v4.2.2

- name: Git config
run: |
git config --global user.name oriy
git config --global user.email 2827449+oriy@users.noreply.github.com

- name: Push dummy PR
run: |
git branch -d "${{ env.PR_BRANCH }}" 2>/dev/null || true
git checkout -b "${{ env.PR_BRANCH }}"
touch dummy && git add dummy
git commit -am 'test ref merge'
git push --set-upstream --force origin HEAD:"${{ env.PR_BRANCH }}"
git remote -v
gh pr create --title "test missing git ref" --body "" || echo "pr might have been already open"
echo "PR_NUMBER=$(gh pr view --repo $GITHUB_REPOSITORY "${{ env.PR_BRANCH }}" --json number --jq ".number")" >> $GITHUB_ENV

- name: Checkout PR merge
uses: actions/checkout@v4.2.2
with:
ref: refs/pull/${{ env.PR_NUMBER }}/merge
clean: true

- name: Close and reopen PR
run: |
git checkout "${{ env.PR_BRANCH }}"
gh pr close --repo $GITHUB_REPOSITORY "${{ env.PR_BRANCH }}"
echo "wait few seconds"
for i in {1..5}; do
sleep 1
printf "."
done
echo
gh pr reopen --repo $GITHUB_REPOSITORY "${{ env.PR_BRANCH }}"

- name: Checkout PR merge once again after PR reopen
uses: actions/checkout@v4.2.2
with:
ref: refs/pull/${{ env.PR_NUMBER }}/merge
clean: true