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

Doesn't fail when missing git #260

Closed
MatthijsBurgh opened this issue Nov 1, 2022 · 4 comments · Fixed by #261
Closed

Doesn't fail when missing git #260

MatthijsBurgh opened this issue Nov 1, 2022 · 4 comments · Fixed by #261
Labels
bug Something isn't working

Comments

@MatthijsBurgh
Copy link

git-auto-commit Version

V4

Machine Type

Ubuntu (eg. ubuntu-latest)

Bug description

I am using the container option of GH actions. My container doesn't have git installed. So your script tries to call git, but it doesn't exist.

I would expect your action would fail in that case. But it doesn't. It just exits with success.

Steps to reproduce

Use the container option of a job in GH actions in combination with a container without git installed.

Tried solutions

Temporary workaround is just to install git manually.

Example Workflow

jobs:
  job_id:
    name: JOB_NAME
    runs-on: ubuntu-latest
    container:
      image: CONTAINER_WITHOUT_GIT
    steps:
      - uses: stefanzweifel/git-auto-commit-action@v4
        ...

Relevant log output

Run stefanzweifel/git-auto-commit-action@v4
  with:
    commit_message: Update Build
    file_pattern: build/*.js
    repository: .
    commit_user_name: github-actions[bot]
    commit_user_email: github-actions[bot]@users.noreply.github.com
    commit_author: MatthijsBurgh <MatthijsBurgh@users.noreply.github.com>
    skip_dirty_check: false
    skip_fetch: false
    skip_checkout: false
    disable_globbing: false
    create_branch: false
  env:
    ROS_DISTRO: noetic
/usr/bin/docker exec  26ef51d71514a8ec76f32381a7b5a5eb419c2349484f3a2d057c99c41dd5e798 sh -c "cat /etc/*release | grep ^ID"
Started: bash /__w/_actions/stefanzweifel/git-auto-commit-action/v4/entrypoint.sh
INPUT_REPOSITORY value: .
INPUT_STATUS_OPTIONS: 
INPUT_FILE_PATTERN: build/*.js
/__w/_actions/stefanzweifel/git-auto-commit-action/v4/entrypoint.sh: line 59: git: command not found
Working tree clean. Nothing to commit.
@MatthijsBurgh MatthijsBurgh added the bug Something isn't working label Nov 1, 2022
@stefanzweifel
Copy link
Owner

Thanks for reporting!
Even if it should be obvious that git is required for this action to work, adding a little check at the beginning of the script and then failing hard if git can't be found, shouldn't be too complex.

Will add this in the upcoming days.

@MatthijsBurgh
Copy link
Author

MatthijsBurgh commented Nov 1, 2022

After manually installing git just before running this action. I get the following error. (src)

/usr/bin/docker exec  af011818fd5442280ae04551d713f43af5ca547e518cc81ce1c146d5fded6e68 sh -c "cat /etc/*release | grep ^ID"
Started: bash /__w/_actions/stefanzweifel/git-auto-commit-action/v4/entrypoint.sh
INPUT_REPOSITORY value: .
INPUT_STATUS_OPTIONS: 
INPUT_FILE_PATTERN: build/*.js
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Working tree clean. Nothing to commit.

Because there wasn't any git in the container. The checkout action just downloaded the repo via the REST API. Therefore the files are there, but the folder isn't a git repo. I think this error is also created in the _git_is_dirty function. In such an event, it would also be nice to let the action end with an error.

@stefanzweifel
Copy link
Owner

I've updated the Action to check if git is available at the very beginning of the execution flow (#261).
If the binary is missing, the run is stopped and a proper error message is displayed.

Screenshot 2022-11-05 at 11 58 32

This should hopefully also cover the behaviour you mentioned.


A new version has been tagged. If you've been using v4 in your workflows, you don't have to update anything.

Thanks again for reporting this issue and helping making this action a bit better.

@MatthijsBurgh
Copy link
Author

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants