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

Migrating to v4: unresolved github.event.pull_request.url in workflow #52

Closed
pierreprinetti opened this issue Jul 10, 2023 · 4 comments · Fixed by #53
Closed

Migrating to v4: unresolved github.event.pull_request.url in workflow #52

pierreprinetti opened this issue Jul 10, 2023 · 4 comments · Fixed by #53
Assignees
Labels
bug Something isn't working

Comments

@pierreprinetti
Copy link
Contributor

While testing the migration to v4.0.0, the Github action doesn't seem to find any more the pull request referenced with github.event.pull_request.url.

Here's the workflow that stopped working:

name: Pull Request backporting

on:
  pull_request_target:
    types:
      - closed
      - labeled

jobs:
  backporting:
    name: "Backporting"
    # Only react to merged PRs for security reasons.
    # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
    if: >
      github.event.pull_request.merged
      && (
        github.event.action == 'closed'
          && contains(github.event.pull_request.labels.*.name, 'backport-v1')
        || (
          github.event.action == 'labeled'
          && contains(github.event.label.name, 'backport-v1')
        )
      )
    runs-on: ubuntu-latest
    steps:
      - name: Backporting
        uses: kiegroup/git-backporting@573a83f114038bcc514e1766d3cfc5c240618eeb
        with:
          target-branch: v1
          pull-request: ${{ github.event.pull_request.url }}
          auth: ${{ secrets.GITHUB_TOKEN }}

It should be conform to what's documented in the README.

Here's the error I get from Github:

2023-07-10T09:40:39.0291834Z Requested labels: ubuntu-latest
2023-07-10T09:40:39.0292142Z Job defined at: pierreprinetti/gophtest2/.github/workflows/backport_v1.yaml@refs/heads/main
2023-07-10T09:40:39.0292235Z Waiting for a runner to pick up this job...
2023-07-10T09:40:39.2456559Z Job is waiting for a hosted runner to come online.
2023-07-10T09:40:42.0169714Z Job is about to start running on the hosted runner: GitHub Actions 2 (hosted)
2023-07-10T09:40:44.3904829Z Current runner version: '2.305.0'
2023-07-10T09:40:44.3935479Z ##[group]Operating System
2023-07-10T09:40:44.3936041Z Ubuntu
2023-07-10T09:40:44.3936451Z 22.04.2
2023-07-10T09:40:44.3936773Z LTS
2023-07-10T09:40:44.3937058Z ##[endgroup]
2023-07-10T09:40:44.3937413Z ##[group]Runner Image
2023-07-10T09:40:44.3937826Z Image: ubuntu-22.04
2023-07-10T09:40:44.3938137Z Version: 20230702.1.0
2023-07-10T09:40:44.3938718Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20230702.1/images/linux/Ubuntu2204-Readme.md
2023-07-10T09:40:44.3939444Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20230702.1
2023-07-10T09:40:44.3939891Z ##[endgroup]
2023-07-10T09:40:44.3940313Z ##[group]Runner Image Provisioner
2023-07-10T09:40:44.3940701Z 2.0.238.1
2023-07-10T09:40:44.3940984Z ##[endgroup]
2023-07-10T09:40:44.3942088Z ##[group]GITHUB_TOKEN Permissions
2023-07-10T09:40:44.3942811Z Actions: write
2023-07-10T09:40:44.3943172Z Checks: write
2023-07-10T09:40:44.3943730Z Contents: write
2023-07-10T09:40:44.3944230Z Deployments: write
2023-07-10T09:40:44.3944561Z Discussions: write
2023-07-10T09:40:44.3944919Z Issues: write
2023-07-10T09:40:44.3945256Z Metadata: read
2023-07-10T09:40:44.3945556Z Packages: write
2023-07-10T09:40:44.3945944Z Pages: write
2023-07-10T09:40:44.3946295Z PullRequests: write
2023-07-10T09:40:44.3946642Z RepositoryProjects: write
2023-07-10T09:40:44.3947061Z SecurityEvents: write
2023-07-10T09:40:44.3947473Z Statuses: write
2023-07-10T09:40:44.3947817Z ##[endgroup]
2023-07-10T09:40:44.3951546Z Secret source: Actions
2023-07-10T09:40:44.3952301Z Prepare workflow directory
2023-07-10T09:40:44.4714748Z Prepare all required actions
2023-07-10T09:40:44.4909419Z Getting action download info
2023-07-10T09:40:44.7434418Z Download action repository 'kiegroup/git-backporting@573a83f114038bcc514e1766d3cfc5c240618eeb' (SHA:573a83f114038bcc514e1766d3cfc5c240618eeb)
2023-07-10T09:40:45.4685592Z Complete job name: Backporting
2023-07-10T09:40:45.5713630Z ##[group]Run kiegroup/git-backporting@573a83f114038bcc514e1766d3cfc5c240618eeb
2023-07-10T09:40:45.5714144Z with:
2023-07-10T09:40:45.5714390Z   target-branch: v1
2023-07-10T09:40:45.5714818Z   pull-request: https://api.github.com/repos/pierreprinetti/gophtest2/pulls/1
2023-07-10T09:40:45.5715526Z   auth: ***
2023-07-10T09:40:45.5715783Z   dry-run: false
2023-07-10T09:40:45.5716033Z   git-user: GitHub
2023-07-10T09:40:45.5716325Z   git-email: [email protected]
2023-07-10T09:40:45.5716648Z   no-inherit-reviewers: false
2023-07-10T09:40:45.5716924Z ##[endgroup]
2023-07-10T09:40:45.8624129Z [DEBUG] Setting up github client: apiUrl=https://api.github.com/api/v4, token=****
2023-07-10T09:40:45.8626763Z [INFO] Creating octokit instance.
2023-07-10T09:40:45.8647634Z [DEBUG] Parsing configs..
2023-07-10T09:40:45.8650623Z [INFO] Getting pull request pierreprinetti/gophtest2/1.
2023-07-10T09:40:46.0049751Z [ERROR] Something went wrong retrieving pull request
2023-07-10T09:40:46.0052191Z [ERROR] HttpError: Not Found
2023-07-10T09:40:46.0053125Z [INFO] Process failed!
2023-07-10T09:40:46.0383395Z Cleaning up orphan processes

And in particular:

2023-07-10T09:40:45.8650623Z [INFO] Getting pull request pierreprinetti/gophtest2/1.
2023-07-10T09:40:46.0049751Z [ERROR] Something went wrong retrieving pull request
2023-07-10T09:40:46.0052191Z [ERROR] HttpError: Not Found

Thank you!

@lampajr
Copy link
Member

lampajr commented Jul 10, 2023

Hi @pierreprinetti , thanks a lot for raising this issue!

I found the root cause and it seems a regression introduced with Gitlab extension, right now the tool is able to recognize just html urls and not the api url.

Temporary workaround: try using github.event.pull_request.html_url instead of github.event.pull_request.url.

Going to fix that asap :)

@lampajr lampajr added the bug Something isn't working label Jul 10, 2023
@lampajr lampajr self-assigned this Jul 10, 2023
lampajr added a commit to lampajr/git-backporting that referenced this issue Jul 10, 2023
@pierreprinetti
Copy link
Contributor Author

wow that was fast. Thanks!

@lampajr
Copy link
Member

lampajr commented Jul 10, 2023

wow that was fast. Thanks!

it was pretty smooth and hopefully it should cover all cases - @pierreprinetti do you mind to give it a check with your use case (remember to change to main), otherwise I will reopen this issue.

@pierreprinetti
Copy link
Contributor Author

Worked like a charm! Thank you.

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

Successfully merging a pull request may close this issue.

2 participants