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

It doesn't seem to be working properly @1.2.0 ~ @1.3.1 #83

Open
xiaocang opened this issue Oct 25, 2021 · 3 comments
Open

It doesn't seem to be working properly @1.2.0 ~ @1.3.1 #83

xiaocang opened this issue Oct 25, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@xiaocang
Copy link

Hi, @srggrs
I can reproduce the problem with following script, the get_next_utl_from_headers would result in an empty string:

get_next_url_from_headers() {
  _HEADERS_FILE=$1
  grep -i '^link' "$_HEADERS_FILE" | tr ',' '\n'| grep \"next\" | sed 's/.*<\(.*\)>.*/\1/'
}

find_project_id() {
  _PROJECT_TYPE="$1"
  _PROJECT_URL="$2"

  case "$_PROJECT_TYPE" in
    org)
      _ORG_NAME=$(echo "$_PROJECT_URL" | sed -e 's@https://github.com/orgs/\([^/]\+\)/projects/[0-9]\+@\1@')
      _ENDPOINT="https://api.github.com/orgs/$_ORG_NAME/projects?per_page=100"
      ;;
    user)
      _USER_NAME=$(echo "$_PROJECT_URL" | sed -e 's@https://github.com/users/\([^/]\+\)/projects/[0-9]\+@\1@')
      _ENDPOINT="https://api.github.com/users/$_USER_NAME/projects?per_page=100"
      ;;
    repo)
      _ENDPOINT="https://api.github.com/repos/$GITHUB_REPOSITORY/projects?per_page=100"
      ;;
  esac

  _NEXT_URL="$_ENDPOINT"

  while : ; do

    _PROJECTS=$(curl -s -X GET -u "$GITHUB_ACTOR:$TOKEN" --retry 3 \
            -H 'Accept: application/vnd.github.inertia-preview+json' \
            -D /tmp/headers \
            "$_NEXT_URL")

    _PROJECTID=$(echo "$_PROJECTS" | jq -r ".[] | select(.html_url == \"$_PROJECT_URL\").id")
    _NEXT_URL=$(get_next_url_from_headers '/tmp/headers')

    if [ "$_PROJECTID" != "" ]; then
      echo "$_PROJECTID"
    elif [ "$_NEXT_URL" == "" ]; then
      echo "No project was found." >&2
      exit 1
    fi
  done

  unset _PROJECT_TYPE _PROJECT_URL _ORG_NAME _USER_NAME _ENDPOINT _PROJECTS _PROJECTID _NEXT_URL
}

find_project_id "org" "https://github.com/orgs/openresty/projects/1"

the content of /tmp/headers is:

HTTP/2 200 
server: GitHub.com
date: Mon, 25 Oct 2021 07:00:23 GMT
content-type: application/json; charset=utf-8
content-length: 1646
cache-control: public, max-age=60, s-maxage=60
vary: Accept
etag: "75aa4315bf12c4814a229ad32207937de51f039b41eb2ab7746085551dfd67f2"
x-github-media-type: github.v3; param=inertia-preview; format=json
x-ratelimit-limit: 60
x-ratelimit-remaining: 56
x-ratelimit-reset: 1635148646
x-ratelimit-used: 4
x-ratelimit-resource: core
access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
access-control-allow-origin: *
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'
vary: Accept-Encoding, Accept, X-Requested-With
x-github-request-id: 592C:28A4:56BB0D:676DB9:61765607
@srggrs
Copy link
Owner

srggrs commented Oct 26, 2021

@tspascoal can you help since you developed that bit? thx

@srggrs srggrs added the bug Something isn't working label Oct 26, 2021
@srggrs
Copy link
Owner

srggrs commented Nov 17, 2021

@xiaocang Btw I run the code above and I currently retrieve _PROJECTID correctly. This will be injected in here. Maybe the issue is in this line, that will stop the action?

@xiaocang
Copy link
Author

@srggrs Thanks for reply, I agree with you.

Could you help fix this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants