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

has_new_commits returns true always #64

Open
sawanverma opened this issue Dec 6, 2022 · 4 comments
Open

has_new_commits returns true always #64

sawanverma opened this issue Dec 6, 2022 · 4 comments

Comments

@sawanverma
Copy link

Even if the target branch is up to date with the upstream repo, the has_new_commits always returns true. I wanted to run another step but this issue is blocking. Can you please suggest?

@aormsby
Copy link
Owner

aormsby commented Dec 7, 2022

What version are you running?

@sawanverma
Copy link
Author

sawanverma commented Dec 7, 2022

aormsby/[email protected].

My configuration looks like following

steps:
# REQUIRED step
# Step 1: run a standard checkout action, provided by github
- name: Checkout target repo
uses: actions/checkout@v2
with:
ref: stage
# REQUIRED if your upstream repo is private (see wiki)
persist-credentials: false

  • name: Sync upstream changes
    id: sync
    uses: aormsby/[email protected]
    with:
    target_sync_branch: stage
    # REQUIRED 'target_repo_token' exactly like this!
    target_repo_token: ${{ secrets.WORKFLOW_TOKEN }}
    upstream_sync_branch: master
    upstream_sync_repo: my_upstream_repo
    upstream_repo_access_token: ${{ secrets.WORKFLOW_TOKEN }}

      # Set test_mode true to run tests instead of the true action!!
      test_mode: false
    

Step 3: Display a sample message based on the sync output var 'has_new_commits'

- name: New commits found
  if: steps.sync.outputs.has_new_commits == 'true'
  run: echo "New commits were found to sync."

- name: No new commits
  if: steps.sync.outputs.has_new_commits == 'false'
  run: echo "There were no new commits."
  
- name: Show value of 'has_new_commits'
  run: echo ${{ steps.sync.outputs.has_new_commits }}

=============================
While running the action, I also found that there was this following error

fatal: could not read Username for 'https://github.com/': No such device or address

The complete logs is as following

Sync upstream changes ---->
28s
Run aormsby/[email protected]
with:
target_sync_branch: stage
target_repo_token: ***
upstream_sync_branch: master
upstream_sync_repo: my_upstream_repo
upstream_repo_access_token: ***
test_mode: false
git_log_format_args: --pretty=oneline
git_config_user: GH Action - Upstream Sync
git_config_email: [email protected]
git_config_pull_rebase: false
host_domain: github.com
shallow_since: 1 month ago
/usr/bin/sh /home/runner/work/_actions/aormsby/Fork-Sync-With-Upstream-action/v3.4/entry/config_and_run.sh
Running ACTION...

Setting git config from input vars. (Skips config for all inputs set to 'null'.)
SUCCESS

Checking out target branch 'stage' for sync.
Already on 'stage'
Your branch is up to date with 'origin/stage'.
Target branch checked out
SUCCESS

Setting upstream repo to 'my_upstream_repo'.
SUCCESS

Checking for new commits on upstream branch.

fatal: could not read Username for 'https://github.com/': No such device or address

No previous sync found from upstream repo. Syncing entire commit history.

Syncing new commits...
Nothing new to pack.
From https://github.com/my_upstream_repo

  • branch master -> FETCH_HEAD
    Already up to date.
    SUCCESS

Pushing synced data to target branch.
Everything up-to-date

SUCCESS

Resetting git config to previous settings.
Reset Complete

Action Complete
New Commits Found------->
0s
Run echo "New commits were found to sync."
echo "New commits were found to sync."
shell: /usr/bin/bash -e {0}
New commits were found to sync.

My question is since as per above, it says Everything up-to-date, then why its finding new commit?

What I am missing here? Can you please let me know? Thanks in advance for all the help.

@aormsby
Copy link
Owner

aormsby commented Dec 30, 2022

The output syntax was updated in #57. I wonder if maybe the syntax in the actions.yml file needs to be updated also. Not sure, will have to look over the docs.

@kurorinchan
Copy link

I believe the problem is this line

elif [ -n "${BRANCH_WITH_LATEST}" ]; then

It should be -z instead of -n. If the hash (commit) is included, the name of the branch is output hence non-empty. Otherwise it's empty (and the error message goes to stderr).

So the work around would be to invert the boolean in your action for the current version. Remove the inversion once fixed.

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

3 participants