[GH-ISSUE #71] don't set GITHUB_SHA when working tree is unclean #44

Closed
opened 2026-03-01 21:39:21 +03:00 by kerem · 5 comments
Owner

Originally created by @maxheld83 on GitHub (Jul 2, 2019).
Original GitHub issue: https://github.com/nektos/act/issues/71

it appears that even when the working tree is unclean, act sets the GITHUB_SHA env var to whatever the last git commit on that branch was.

This seems friendly, but can lead to some pretty unexpected behavior, because AFAIK act actually runs with the unclean working tree, so the GITHUB_SHA is actually kind of wrong.

In any kind of situation where you're referencing something via GITHUB_SHA this can get weird (e.g. I am FROM:ing Docker images in the version of the GITHUB_SHA).

I think it would be safer behavior to either:

  • don't set a GITHUB_SHA when the working tree is unclean
  • do not allow act to run on an unclean working tree (safest of them all maybe, because that's how github actions actually works, it never runs on unclean trees).
Originally created by @maxheld83 on GitHub (Jul 2, 2019). Original GitHub issue: https://github.com/nektos/act/issues/71 it appears that even when the working tree is unclean, act sets the `GITHUB_SHA` env var to whatever the last git commit on that branch was. This seems friendly, but can lead to some pretty unexpected behavior, because AFAIK act *actually* runs with the unclean working tree, so the `GITHUB_SHA` is actually kind of wrong. In any kind of situation where you're referencing something via `GITHUB_SHA` this can get weird (e.g. I am `FROM:`ing Docker images in the version of the `GITHUB_SHA`). I think it would be safer behavior to either: - don't set a `GITHUB_SHA` when the working tree is unclean - do not allow act to run on an unclean working tree (safest of them all maybe, because that's how github actions actually works, it never runs on unclean trees).
Author
Owner

@themightychris commented on GitHub (Oct 29, 2019):

In the spirit of act, it would be nice if you could run it against working trees, act could do something like this:

export GIT_INDEX_FILE="$(git rev-parse --git-dir)/index.act"
git reset HEAD
git add --all
WORK_TREE_HASH=$(git write-tree)
export GITHUB_SHA=$(git commit-tree -p HEAD -m "snapshot working tree" ${WORK_TREE_HASH})
<!-- gh-comment-id:547674526 --> @themightychris commented on GitHub (Oct 29, 2019): In the spirit of act, it would be nice if you could run it against working trees, act could do something like this: ```bash export GIT_INDEX_FILE="$(git rev-parse --git-dir)/index.act" git reset HEAD git add --all WORK_TREE_HASH=$(git write-tree) export GITHUB_SHA=$(git commit-tree -p HEAD -m "snapshot working tree" ${WORK_TREE_HASH}) ```
Author
Owner

@themightychris commented on GitHub (Mar 18, 2020):

hey bot, this is still a good idea! And it has concrete implementation notes

<!-- gh-comment-id:600706496 --> @themightychris commented on GitHub (Mar 18, 2020): hey bot, this is still a good idea! And it has concrete implementation notes
Author
Owner

@github-actions[bot] commented on GitHub (May 18, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:629883281 --> @github-actions[bot] commented on GitHub (May 18, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@github-actions[bot] commented on GitHub (Jul 18, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:660390206 --> @github-actions[bot] commented on GitHub (Jul 18, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@github-actions[bot] commented on GitHub (Sep 19, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:695136730 --> @github-actions[bot] commented on GitHub (Sep 19, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#44
No description provided.