Skip to content

Commit

Permalink
github/actions: migrate from "hub" to "gh"
Browse files Browse the repository at this point in the history
GitHub has removed "hub" from their runners since Oct.2, 2023. The
recommendation is to use "gh" instead. One benefits is that "gh"
has a command for merging the PR, with option to rebase. This allows
simpler action script and makes it possible to make "rebase" as the
only merge strategy allowed.

Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
  • Loading branch information
j-xiong committed Oct 31, 2023
1 parent cbaf4a5 commit ef95638
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/gh-man.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi
# Yes, we committed something. Push the branch and make a PR.
# Extract the PR number.
git push --set-upstream origin $branch_name
url=`hub pull-request -b gh-pages -m 'Update GH man pages'`
url=`gh pr create --base gh-pages --title 'Update GH man pages' --body ''`
pr_num=`echo $url | cut -d/ -f7`

# Wait for the required "DCO" CI to complete
Expand All @@ -67,9 +67,9 @@ echo "Waiting up to $max_seconds seconds for DCO CI to complete..."
while test $i -lt $i_max; do
date
set +e
status=`hub ci-status --format "%t %S%n" | egrep '^DCO' | awk '{ print $2 }'`
status=`gh pr checks | egrep '^DCO' | awk '{ print $2 }'`
set -e
if test "$status" = "success"; then
if test "$status" = "pass"; then
echo "DCO CI is complete!"
break
fi
Expand All @@ -79,12 +79,15 @@ done

status=0
if test $i -lt $i_max; then
# Sadly, there is no "hub" command to merge a PR. So do it by
# hand.
curl \
-XPUT \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$pr_num/merge
# rebase the commit onto the base branch
gh pr merge $pr_num -r

# command to do it by hand when "hub" was used which didn't have command
# to merge a PR. keep it here for reference.
#curl \
# -XPUT \
# -H "Authorization: token $GITHUB_TOKEN" \
# https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$pr_num/merge
else
echo "Sad panda; DCO CI didn't complete -- did not merge $url"
status=1
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/nroff-elves.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fi
# Yes, we committed something. Push the branch and make a PR.
# Extract the PR number.
git push --set-upstream origin $branch_name
url=`hub pull-request -b $BASE_REF -m 'Update nroff-generated man pages'`
url=`gh pr create --base $BASE_REF --title 'Update nroff-generated man pages' --body ''`
pr_num=`echo $url | cut -d/ -f7`

# Wait for the required "DCO" CI to complete
Expand All @@ -80,9 +80,9 @@ echo "Waiting up to $max_seconds seconds for DCO CI to complete..."
while test $i -lt $i_max; do
date
set +e
status=`hub ci-status --format "%t %S%n" | egrep '^DCO' | awk '{ print $2 }'`
status=`gh pr checks | egrep '^DCO' | awk '{ print $2 }'`
set -e
if test "$status" = "success"; then
if test "$status" = "pass"; then
echo "DCO CI is complete!"
break
fi
Expand All @@ -92,12 +92,15 @@ done

status=0
if test $i -lt $i_max; then
# Sadly, there is no "hub" command to merge a PR. So do it by
# hand.
curl \
-XPUT \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$pr_num/merge
# rebase the commit onto the base branch
gh pr merge $pr_num -r

# command to do it by hand when "hub" was used which didn't have command
# to merge a PR. keep it here for reference.
#curl \
# -XPUT \
# -H "Authorization: token $GITHUB_TOKEN" \
# https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$pr_num/merge
else
echo "Sad panda; DCO CI didn't complete -- did not merge $url"
status=1
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/nroff-elves.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
- name: Check out the git repo
uses: actions/checkout@v4

- name: Get the required packages
run: sudo apt install -y pandoc hub

- name: Build the nroff man pages
run: .github/workflows/nroff-elves.sh
env:
Expand Down

0 comments on commit ef95638

Please sign in to comment.