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

Update action.yaml #19

Merged
merged 3 commits into from
Dec 8, 2023
Merged
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: 5 additions & 5 deletions ffmerge/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ runs:
branch=$(gh pr view ${{github.event.issue.number}} --json headRefName --jq '.headRefName')
target=$(gh pr view ${{github.event.issue.number}} --json baseRefName --jq '.baseRefName')
echo "from $branch to $target"
status_is_failed=$(echo $(gh pr checks ${{github.event.issue.number}} --required) | grep 'fail') || true
status_is_failed=$(echo $(gh pr checks ${{github.event.issue.number}} --required 2> /dev/null) | grep 'fail') || true

if [[ -n $status_is_failed ]]; then
>&2 echo "Pull request checks have not passed. Try again once checks have passed."
echo -e "Fast forward failed - not all checks have passed.\n\n<img src=\"https://media3.giphy.com/media/YTJXDIivNMPuNSMgc0/giphy.gif\"/>" | gh pr comment ${{github.event.issue.number}} -F-
exit 1
fi

status_is_pending=$(echo $(gh pr checks ${{github.event.issue.number}} --required) | grep 'pending') || true
status_is_pending=$(echo $(gh pr checks ${{github.event.issue.number}} --required 2> /dev/null) | grep 'pending') || true

pending_iter_total=1
while [[ -n $status_is_pending ]] && [[ $pending_iter_total -le 6 ]]; do
echo "Waiting to see non-pending state...($pending_iter_total/6)"
sleep 10
((pending_iter_total++))
status_is_pending=$(echo $(gh pr checks ${{github.event.issue.number}} --required) | grep 'pending') || true
status_is_pending=$(echo $(gh pr checks ${{github.event.issue.number}} --required 2> /dev/null) | grep 'pending') || true
done

status_is_success=$(echo $(gh pr checks ${{github.event.issue.number}} --required) | grep 'pass') || true
status_is_not_success=$(echo $(gh pr checks ${{github.event.issue.number}} --required 2> /dev/null) | grep -E '(pending|fail)') || true

if [[ -n $status_is_success ]]; then
if [[ -z $status_is_not_success ]]; then
git checkout $branch && git pull
git checkout $target && git pull
result=$(git merge --ff-only $branch 2>&1 && git push origin HEAD 2>&1) || exit_code=$?
Expand Down