pull-request icon indicating copy to clipboard operation
pull-request copied to clipboard

Add third-party repository support

Open m4heshd opened this issue 4 years ago • 6 comments

This PR adds following features:

  • Manual input for target repository (destination_repository)
  • Automatic querying of the checked out repository (#55)

Sample usage:

jobs:
  pull-request:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        repository: "octocat/hello-world"
    - name: pull-request
      uses: repo-sync/pull-request@v2
      with:
        destination_branch: "main"
        github_token: ${{ secrets.GITHUB_TOKEN }}

In this example, the PR will be created in octocat/hello-world.

Notes:

🔵 Manual input has the highest priority. Final fallback is GITHUB_REPOSITORY env var 🔵 Supports both bare and non-bare repositories 🔵 Does not depend on actions/checkout

🟢 Minimal amount of modifications to the original source 🟢 Changes are fully backwards compatible 🟢 Functionality has been tested in numerous possible scenarios

Related issues: #18, #55

m4heshd avatar Aug 24 '21 18:08 m4heshd

Hey I've just come across this today, it seems to be exactly what I need 🎉 is there any chance of getting it merged?

mansona avatar Feb 16 '22 11:02 mansona

@mansona You can use my PR branch for the moment. I use this on pretty much all of my projects.

    - name: pull-request
      uses: m4heshd/pull-request@third-party-repos
      with:
        destination_branch: "main"
        github_token: ${{ secrets.GITHUB_TOKEN }}

Or you can simply fork it and use.

m4heshd avatar Feb 16 '22 13:02 m4heshd

Thanks for the bump. Will review and try to merge it soon.

wei avatar Feb 16 '22 13:02 wei

@m4heshd yes I have been doing that to test this out 👍

one thing I will say as possible feedback, I had accidentally put the wrong name for the token for this action and it failed to create the PR, but it still showed as succeeding 🤔

https://github.com/mansona/test-copy-file-source/runs/5235589544?check_suite_focus=true#step:6:25

I don't know exactly how to do this but you might want to make sure that the exit code is correct in this scenario since I suspect that will be the most common error people will have (i.e. not having the right credentials set up)

mansona avatar Feb 17 '22 17:02 mansona

@mansona Hmm.. 🤔. Gonna have to take a look at that. I already see what the issue is but need some free time on my hands to do some tests.

m4heshd avatar Feb 21 '22 10:02 m4heshd

@m4heshd do you want to share the issue and maybe I can take a look? i.e. if you know what the problem is then maybe write a brief description here and if i have time I can take a look 👍

mansona avatar Mar 10 '22 09:03 mansona

I'm trying to use the action in a private repo to no avail:

Given the following config:

name: Make PRs

on:
  workflow_dispatch:

jobs:
  createPullRequest:
    runs-on: ubuntu-latest
    steps:
      # https://github.com/actions/checkout v3.1.0
      - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
        with:
          repository: some/repo
          token: ${{ secrets.TOKEN }}

      - name: Mark github workspace as safe
        run: git config --global --add safe.directory /github/workspace

      - name: Create Pull Request
        uses: m4heshd/pull-request@third-party-repos
        with:
          source_branch: main
          destination_branch: dev
          pr_title: 'Merge released code into dev branch'
          pr_body: *An automated PR*
          github_token: ${{ secrets.TOKEN }}

we're getting an error:

fatal: detected dubious ownership in repository at '/github/workspace'
To add an exception for this directory, call:

	git config --global --add safe.directory /github/workspace

steven-pribilinskiy avatar Dec 20 '22 08:12 steven-pribilinskiy

@mansona Sorry I missed your last response. I'm gonna take a look at it again.

@steven-prybylynskyi It's because of #84. Not related to this PR. But it should be fixed now since the changes are merged.

Meanwhile, can y'all try my fork (m4heshd/pull-request@third-party-repos) again and give me an update?

m4heshd avatar Dec 21 '22 04:12 m4heshd

@ReenigneArcher I saw your issue in my mail and now you've deleted it. Can you confirm if everything's working correctly?

m4heshd avatar Dec 22 '22 03:12 m4heshd

@ReenigneArcher I saw your issue in my mail and now you've deleted it. Can you confirm if everything's working correctly?

Sorry, my original issue was a dumb mistake on my part. I was accidentally using pr_template instead of pr_body, due to a copy and paste from another workflow of mine.

I do have one issue here though.

      - name: Create Pull Request
        # uses: repo-sync/pull-request@v2
        # use this branch temporary to support creating PR against another repo
        uses: m4heshd/pull-request@third-party-repos
        with:
          destination_repository: ${{ github.repository_owner }}/somerepo
          source_branch: ${{ env.update_branch }}
          destination_branch: nightly
          pr_title: "Update"
          pr_body: "Update with changes from ${{ github.repository }}"
          pr_assignee: ${{ secrets.GH_BOT_NAME }}
          pr_draft: false
          pr_label: "dependencies, submodules"
          pr_allow_empty: false
          github_token: ${{ secrets.GH_BOT_TOKEN }}

PR labels are not being added to the PR that's created.

Here is the created PR: https://github.com/LizardByte/Sunshine/pull/603 And the logs from the workflow run with this action: https://github.com/LizardByte/build-deps/actions/runs/3754737056/jobs/6379211844#step:6:68

Note that the two labels I removed are added by another workflow... the two I specified here are not added at all.

ReenigneArcher avatar Dec 22 '22 03:12 ReenigneArcher

@ReenigneArcher You can't have spaces between the labels list.

m4heshd avatar Dec 22 '22 03:12 m4heshd

@wei Can we get this very useful PR merged? It's quite difficult to keep a 16-month-old PR up to date while resolving merge conflicts.

m4heshd avatar Dec 24 '22 01:12 m4heshd

@allcontributors add @m4heshd for code

wei avatar Dec 24 '22 01:12 wei

@wei

I've put up a pull request to add @m4heshd! :tada:

allcontributors[bot] avatar Dec 24 '22 01:12 allcontributors[bot]

@wei Thank you for merging and Merry Christmas to you as well fellow dev. 🎄🎅🏽

m4heshd avatar Dec 24 '22 01:12 m4heshd

It's now available at

repo-sync/pull-request@v2
repo-sync/[email protected]
docker://ghcr.io/repo-sync/pull-request:v2
docker://ghcr.io/repo-sync/pull-request:v2.10

wei avatar Dec 24 '22 01:12 wei