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

This isn't recognizing changes between two branches of two repos #2523

Closed
tsaxking opened this issue Nov 5, 2023 · 2 comments
Closed

This isn't recognizing changes between two branches of two repos #2523

tsaxking opened this issue Nov 5, 2023 · 2 comments

Comments

@tsaxking
Copy link

tsaxking commented Nov 5, 2023

I am trying to set up a few repo:

  • One main repo as a template for several others, let's call it A
  • Several other repos that are essentially forked off A, let's call these B (These aren't forked, they're created blank and I want to update)

My goal is for whenever I push to main on A, it will create a pull request of all B repos

My yaml file:

jobs:
  merge-template:
    runs-on: ubuntu-latest

  strategy:
    matrix:
      templates: [
        B # list of 'cloned' repositories
      ]

    - uses: actions/checkout@v3
      with:
        fetch-depth: 0

    - name: 'Setup ssh-agent'
      uses: 'webfactory/[email protected]'
      with:
        ssh-private-key: ${{ secrets.SSH_PRIVATE }}

    - name: 'Setup git config and repository'
      run: |
        git config --local user.name "Webpack Bot"
        git config --local user.email "github-actions[bot]@users.noreply.github.com"
        git config --global core.compression 0
        rm -rf ./.github/workflows/merge-template.yml # So it doesn't trigger over and over

        cd ..
        git clone [email protected]:tsaxking/template-${{ matrix.templates }}.git
        cd ./webpack-template

    - name: Create Pull Request
      uses: peter-evans/create-pull-request@v5
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        commit-message: 'Merge template'
        title: 'Merge template'
        body: '[blah]'
        branch: merge-template
        author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
        delete-branch: true
        branch-suffix: timestamp
        labels: |
          merge-template
          auto-merge
        base: main
        draft: false
        reviewers: tsaxking
        assignees: tsaxking
        path: ../template-${{ matrix.templates }}

There are no error messages, but whenever I push a change to A it doesn't detect differences between the different repositories, as given by "Create or update the pull request branch" log:

/usr/bin/git symbolic-ref HEAD --short
  main
  Working base is branch 'main'
  /usr/bin/git checkout --progress -B f3d1aeda-40[45](https://github.com/tsaxking/webpack-template/actions/runs/6759499736/job/18372211343#step:6:50)-4588-88ea-41d5a59abee9 HEAD --
  Switched to a new branch 'f3d1aeda-4045-4588-88ea-41d5a59abee9'
  /usr/bin/git status --porcelain -unormal --
  /usr/bin/git diff --quiet --
  /usr/bin/git diff --quiet --staged --
  /usr/bin/git stash push --include-untracked
  No local changes to save
  Resetting working base branch 'main'
  /usr/bin/git checkout --progress main --
  Switched to branch 'main'
  Your branch is up to date with 'origin/main'.
  /usr/bin/git reset --hard origin/main
  HEAD is now at 520c87d remove main
  /usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force origin merge-template-1699162922:refs/remotes/origin/merge-template-1699162922
  fatal: couldn't find remote ref merge-template-1699162922
  Pull request branch 'merge-template-1699162922' does not exist yet.
  /usr/bin/git checkout --progress -B merge-template-1699162922 f3d1aeda-4045-4588-88ea-41d5a59abee9 --
  Switched to a new branch 'merge-template-1699162922'
  /usr/bin/git rev-list --right-only --count main...merge-template-1699162922
  0
  Branch 'merge-template-1699162922' is not ahead of base 'main' and will not be created
  /usr/bin/git rev-parse HEAD
  520c87db0e8103831bb3e[50](https://github.com/tsaxking/webpack-template/actions/runs/6759499736/job/18372211343#step:6:55)58a4fbaf1589fad1e
  /usr/bin/git branch --delete --force f3d1aeda-4045-4588-88ea-41d5a59abee9
  Deleted branch f3d1aeda-4045-4588-88ea-41d5a59abee9 (was [52](https://github.com/tsaxking/webpack-template/actions/runs/6759499736/job/18372211343#step:6:57)0c87d).
  /usr/bin/git checkout --progress main --
  Switched to branch 'main'
  Your branch is up to date with 'origin/main'.

It is entirely possible I am not using this as intended, but it seems like that's the purpose of this repo, although I am unsure. Please advise!

@peter-evans
Copy link
Owner

Hi @tsaxking

It doesn't look like you are checking out the base of each repo in the matrix.

    - uses: actions/checkout@v3
      with:
        repository: <repo from list B>
        fetch-depth: 0

Also, because this workflow is running in a separate repo you won't be able to use GITHUB_TOKEN because it's only scoped to the current repo. You'll need a PAT.

As for cloning the template. I think it might be better just to use the official checkout action to checkout using path to a different location. Then just copy the template code to overwrite the current code in the main branch of each repo in list B. Then call the action to raise the PR.

@peter-evans
Copy link
Owner

Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants