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

Trouble with setting push: options #320

Closed
barrettj12 opened this issue Nov 2, 2021 · 2 comments
Closed

Trouble with setting push: options #320

barrettj12 opened this issue Nov 2, 2021 · 2 comments
Labels
status: pending More info is needed before deciding what to do status: stale Inactive issues and PRs

Comments

@barrettj12
Copy link

barrettj12 commented Nov 2, 2021

Bug description

I am trying to set the options so that git will force push. Following the README, I originally tried to set the following option in my config:

push: origin ${branch input} --force --set-upstream

but this gave the following error:

error: src refspec ${branch does not match any
error: src refspec input} does not match any

From this, I figured that ${branch input} was not supposed to be used literally in the command. From this SO question, I found out that ${GITHUB_REF##*/} should return the current branch, so I tried changing it to:

push: origin ${GITHUB_REF##*/} --force --set-upstream

However, this now makes it so that nothing at all is pushed:

  > Pushing commit to repo...
  
  {
    pushed: [],
    repo: '<my-repo>',
    remoteMessages: RemoteMessageSummary { all: [] }
  }
  > No tags to push.

while the log should look something like

  > Pushing commit to repo...
  
  {
    pushed: [],
    update: {
      head: { local: 'refs/heads/main', remote: 'refs/heads/main' },
      hash: { from: '<hash1>', to: '<hash2>' }
    },
    branch: { local: 'main', remote: 'main', remoteName: 'origin' },
    repo: '<my-repo>',
    ref: { local: 'refs/remotes/origin/main' },
    remoteMessages: RemoteMessageSummary { all: [] }
  }
  > No tags to push.

Workflow used

on: [push, pull_request]
jobs:
  make-pdf:
    runs-on: ubuntu-latest
    steps:
      - (... step that creates `main.pdf` file in CI env)
      - name: Upload PDF to repo
        uses: EndBug/add-and-commit@v7.4.0
        with:
          add: 'main.pdf'
          pull: 'NO-PULL'
#          push: origin ${GITHUB_REF##*/} --force --set-upstream

Expected behavior

The main.pdf file would be added to the current branch in my repo.

@barrettj12 barrettj12 added the status: pending More info is needed before deciding what to do label Nov 2, 2021
@barrettj12 barrettj12 mentioned this issue Nov 2, 2021
@EndBug
Copy link
Owner

EndBug commented Nov 2, 2021

Oh ok, if you're pushing to the same branch that's checked out you can just set push to --force, without anything else, and that should work.

@stale
Copy link

stale bot commented Dec 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale Inactive issues and PRs label Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pending More info is needed before deciding what to do status: stale Inactive issues and PRs
Projects
None yet
Development

No branches or pull requests

2 participants