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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow always fails at the "Create New Branch" stage #43

Closed
nicoddemus opened this issue Nov 21, 2022 · 5 comments 路 Fixed by #44
Closed

Workflow always fails at the "Create New Branch" stage #43

nicoddemus opened this issue Nov 21, 2022 · 5 comments 路 Fixed by #44

Comments

@nicoddemus
Copy link
Contributor

Hi!

First of all thanks for writing this action and making it publicly available. 馃憤

I'm trying to make it to work, however for me it always fails at the Create New Branch stage, and unfortunately I can't see the reason for that from the output:

Create New Branch (refs/heads/main -> gh-actions-update-1669032900)
  Error: Note: checking out 'refs/heads/main'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
    git checkout -b <new-branch-name>
  
  HEAD is now at 3acfbc3 Set explicit permissions in update gh actions workflow
  
  This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.

Using version 0.7.1.

I did try to disable Git LFS (even though doesn't seem like that would be a problem), with the same results.

Any hints?

Thanks

@saadmk11
Copy link
Owner

Hi @nicoddemus, Thanks for reporting the issue.

  • Can you share the workflow file for this action?
  • Do you still get this message after disabling Git LFS (This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.) ?
  • Viewing the full raw log maybe useful here to understand what's going on.

This is the function that creates a new branch:

def create_new_git_branch(base_branch_name: str, new_branch_name: str) -> None:
"""
Create a new git branch from base branch.
"""
with gha_utils.group(
f"Create New Branch ({base_branch_name} -> {new_branch_name})"
):
run_subprocess_command(["git", "checkout", base_branch_name])
run_subprocess_command(["git", "checkout", "-b", new_branch_name])

@nicoddemus
Copy link
Contributor Author

Thanks for the quick response!

Can you share the workflow file for this action?

name: Update GitHub actions

on:
  schedule:
    # At 08:30 on Monday.
    # https://crontab.guru
    - cron: '30 8 * * 1'
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          token: ${{ secrets.WORKFLOW_SECRET }}

      - name: Run GitHub Actions Version Updater
        uses: saadmk11/github-actions-version-updater@v0.7.1
        with:
          token: ${{ secrets.WORKFLOW_SECRET }}
          committer_username: 'Bruno Oliveira'
          committer_email: 'nicoddemus@gmail.com'
          commit_message: 'Update GitHub Actions to their latest versions'
          pull_request_title: 'Pull Request Title'
          update_version_with: 'release-tag'
          release_types: "all"

You will notice that there is no LFS configuration, that's my original attempt. I configured LFS with:

fetch-depth: 0
lfs: false

But this still gives the exact same error.

Do you still get this message after disabling Git LFS

Yes, sorry for not making that clearer.

Viewing the full raw log maybe useful here to understand what's going on.

Here is the relevant part (can't share the full link because it is a private repo):

2022-11-21T12:15:00.4169094Z ##[group]Parse Configuration
2022-11-21T12:15:00.4169358Z Using Configuration:
2022-11-21T12:15:00.4169903Z {'commit_message': '[automated] Update GitHub Actions to their latest versions',
2022-11-21T12:15:00.4170272Z  'extra_workflow_paths': set(),
2022-11-21T12:15:00.4170580Z  'git_committer_email': 'nicoddemus@gmail.com',
2022-11-21T12:15:00.4170913Z  'git_committer_username': 'Bruno Oliveira',
2022-11-21T12:15:00.4171664Z  'github_token': '***',
2022-11-21T12:15:00.4171924Z  'ignore_actions': set(),
2022-11-21T12:15:00.4172205Z  'pull_request_team_reviewers': set(),
2022-11-21T12:15:00.4172530Z  'pull_request_title': 'Pull Request Title',
2022-11-21T12:15:00.4172823Z  'pull_request_user_reviewers': set(),
2022-11-21T12:15:00.4173146Z  'release_types': ['major', 'minor', 'patch'],
2022-11-21T12:15:00.4173439Z  'skip_pull_request': False,
2022-11-21T12:15:00.4173724Z  'update_version_with': 'release-tag'}
2022-11-21T12:15:00.4174129Z ##[endgroup]
2022-11-21T12:15:00.4174492Z ##[group]Configure Git Author
2022-11-21T12:15:00.4203442Z ##[notice]Setting Git Commit User to 'Bruno Oliveira'.
2022-11-21T12:15:00.4212616Z ##[notice]Setting Git Commit email to 'nicoddemus@gmail.com'.
2022-11-21T12:15:00.4213184Z 
2022-11-21T12:15:00.4213190Z 
2022-11-21T12:15:00.4213437Z ##[endgroup]
2022-11-21T12:15:00.4213831Z ##[group]Run GitHub Actions Version Updater
2022-11-21T12:15:00.4214348Z ##[group]Checking ".github/workflows/minimal-linux.yml" for updates
2022-11-21T12:15:00.4214664Z Checking "actions/checkout" for updates...
2022-11-21T12:15:00.4214939Z Found new version for "actions/checkout"
2022-11-21T12:15:00.4216021Z Updating "actions/checkout@v2" with "actions/checkout@v3.1.0"...
2022-11-21T12:15:00.4216331Z Checking "actions/cache" for updates...
2022-11-21T12:15:00.4216590Z Found new version for "actions/cache"
2022-11-21T12:15:00.4216877Z Updating "actions/cache@v3" with "actions/cache@v3.0.11"...
2022-11-21T12:15:00.4217248Z Checking "actions/setup-python" for updates...
2022-11-21T12:15:00.4217596Z Found new version for "actions/setup-python"
2022-11-21T12:15:00.4218006Z Updating "actions/setup-python@v2" with "actions/setup-python@v4.3.0"...
2022-11-21T12:15:00.4218448Z ##[endgroup]
2022-11-21T12:15:00.4218927Z ##[group]Checking ".github/workflows/update-github-actions.yml" for updates
2022-11-21T12:15:00.4219252Z Found new version for "actions/checkout"
2022-11-21T12:15:00.4219551Z Updating "actions/checkout@v2" with "actions/checkout@v3.1.0"...
2022-11-21T12:15:00.4219967Z Checking "saadmk11/github-actions-version-updater" for updates...
2022-11-21T12:15:00.4220411Z No updates found for "saadmk11/github-actions-version-updater"
2022-11-21T12:15:00.4220826Z ##[endgroup]
2022-11-21T12:15:00.4222054Z ##[warning]Workflow file '.github/workflows/minimal_linux.yml' not found
2022-11-21T12:15:00.4222973Z ##[group]Checking ".github/workflows/update-pre-commit.yml" for updates
2022-11-21T12:15:00.4223291Z Found new version for "actions/checkout"
2022-11-21T12:15:00.4223595Z Updating "actions/checkout@v2" with "actions/checkout@v3.1.0"...
2022-11-21T12:15:00.4223997Z Checking "peter-evans/create-pull-request" for updates...
2022-11-21T12:15:00.4224382Z Found new version for "peter-evans/create-pull-request"
2022-11-21T12:15:00.4225067Z Updating "peter-evans/create-pull-request@v3" with "peter-evans/create-pull-request@v4.2.0"...
2022-11-21T12:15:00.4225486Z Found new version for "actions/setup-python"
2022-11-21T12:15:00.4225889Z Updating "actions/setup-python@v2" with "actions/setup-python@v4.3.0"...
2022-11-21T12:15:00.4226325Z ##[endgroup]
2022-11-21T12:15:00.4226733Z ##[group]Checking ".github/workflows/build.yml" for updates
2022-11-21T12:15:00.4227029Z Found new version for "actions/checkout"
2022-11-21T12:15:00.4227322Z Updating "actions/checkout@v2" with "actions/checkout@v3.1.0"...
2022-11-21T12:15:00.4227689Z Checking "actions/upload-artifact" for updates...
2022-11-21T12:15:00.4228049Z Found new version for "actions/upload-artifact"
2022-11-21T12:15:00.4228465Z Updating "actions/upload-artifact@v2" with "actions/upload-artifact@v3.1.1"...
2022-11-21T12:15:00.4228783Z Checking "actions/cache" for updates...
2022-11-21T12:15:00.4229041Z Found new version for "actions/cache"
2022-11-21T12:15:00.4229341Z Updating "actions/cache@v2" with "actions/cache@v3.0.11"...
2022-11-21T12:15:00.4229684Z Found new version for "actions/setup-python"
2022-11-21T12:15:00.4230080Z Updating "actions/setup-python@v2" with "actions/setup-python@v4.3.0"...
2022-11-21T12:15:00.4230732Z ##[endgroup]
2022-11-21T12:15:00.4231513Z ##[warning]Workflow file '.github/workflows/auto-cancellation.yml' not found
2022-11-21T12:15:00.4232369Z ##[group]Checking ".github/workflows/update-dependencies.yml" for updates
2022-11-21T12:15:00.4232685Z Found new version for "actions/checkout"
2022-11-21T12:15:00.4232988Z Updating "actions/checkout@v2" with "actions/checkout@v3.1.0"...
2022-11-21T12:15:00.4233393Z Found new version for "peter-evans/create-pull-request"
2022-11-21T12:15:00.4233868Z Updating "peter-evans/create-pull-request@v3" with "peter-evans/create-pull-request@v4.2.0"...
2022-11-21T12:15:00.4234276Z Found new version for "actions/setup-python"
2022-11-21T12:15:00.4234675Z Updating "actions/setup-python@v2" with "actions/setup-python@v4.3.0"...
2022-11-21T12:15:00.4235106Z ##[endgroup]
2022-11-21T12:15:00.4235600Z ##[group]Create New Branch (refs/heads/main -> gh-actions-update-1669032900)
2022-11-21T12:15:00.4236735Z ##[error]Note: checking out 'refs/heads/main'.
2022-11-21T12:15:00.4237204Z 
2022-11-21T12:15:00.4237451Z You are in 'detached HEAD' state. You can look around, make experimental
2022-11-21T12:15:00.4237999Z changes and commit them, and you can discard any commits you make in this
2022-11-21T12:15:00.4238359Z state without impacting any branches by performing another checkout.
2022-11-21T12:15:00.4238560Z 
2022-11-21T12:15:00.4238719Z If you want to create a new branch to retain commits you create, you may
2022-11-21T12:15:00.4239132Z do so (now or later) by using -b with the checkout command again. Example:
2022-11-21T12:15:00.4239336Z 
2022-11-21T12:15:00.4239488Z   git checkout -b <new-branch-name>
2022-11-21T12:15:00.4239643Z 
2022-11-21T12:15:00.4239819Z HEAD is now at 3acfbc3 Set explicit permissions in update gh actions workflow
2022-11-21T12:15:00.4240020Z 
2022-11-21T12:15:00.4240446Z This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.
2022-11-21T12:15:00.4240759Z 
2022-11-21T12:15:00.4240765Z 
2022-11-21T12:15:00.5729159Z Post job cleanup.
2022-11-21T12:15:00.7028871Z [command]/usr/bin/git version
2022-11-21T12:15:00.7075049Z git version 2.38.1

This is the function that creates a new branch:

Yes I did browse the action code and found that function, thanks.

The same could be accomplished with a single command btw:

     with gha_utils.group( 
         f"Create New Branch ({base_branch_name} -> {new_branch_name})" 
     ): 
         run_subprocess_command(["git", "checkout", "-b", new_branch_name, base_branch_name])         

Any specific reason why this is done currently with two commands? Not that I think it is related with my problem, just curious. 馃榿

Thanks!

@nicoddemus
Copy link
Contributor Author

Did investigate a bit more, and indeed the problem might be GitLFS:

git-lfs/git-lfs#4346

Seems like this is a problem if GitLFS is not installed in the container running the action, which would explain why this would fail.

Will try to remove the hook manually and see if it works. 馃憤

@nicoddemus
Copy link
Contributor Author

Indeed that was the problem, I fixed by adding an extra step that removed the hooks explicitly:

      - name: Remove LFS hook
        # If the LFS related hooks are present, the GitHub Actions updater
        # will fail because Git will complain about git-lfs not being
        # on the $PATH, because indeed is not available in the action's container.
        # https://github.com/saadmk11/github-actions-version-updater/issues/43
        run: |
          rm .git/hooks/post-checkout
          rm .git/hooks/pre-push

I think this can be solved in this repo in two ways:

  1. Install GitLFS in the container: this will probably increase the container size a bit.
  2. Document the workaround.

I will open a PR with 2) as this might help others with the same problem right away. 馃憤

nicoddemus added a commit to nicoddemus/github-actions-version-updater that referenced this issue Nov 21, 2022
@nicoddemus
Copy link
Contributor Author

Opened #44. 馃憤

nicoddemus added a commit to nicoddemus/github-actions-version-updater that referenced this issue Nov 21, 2022
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

Successfully merging a pull request may close this issue.

2 participants