-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add github-server-url option (and more) #70
Conversation
@spenserblack requesting review |
Co-authored-by: Spenser Black <[email protected]>
Btw do you know what the |
Never actually used |
echo "🟪 Cloning $GITHUB_REPOSITORY.wiki into $INPUT_PATH..." | ||
cd "$INPUT_PATH" | ||
gh repo clone "$GITHUB_REPOSITORY.wiki" .git -- --bare | ||
trap 'rm -rf .git' SIGINT SIGTERM ERR EXIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a good cleanup operation, or is there a better way? bash doesn't really have try-finally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can just naively cleanup at the end without any "try-finally" behavior. The majority of workflows would stop if this action fails, which basically "cleans up," except possibly in a self-hosted runner. On failure, the .git
folder can continue to exist for the user's debug purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added a bunch of logs with using the 🟥🟧🟨🟩🟦🟪⬛ emojis like log levels. i know gh actions have like fancy builtin ::warning::
or something.. should I be using that? 😆
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Yeah, probably best to use the built-in log levels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok if i do that in a separate pr to avoid this getting too big, or do you want me to do it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Yeah, probably best to use the built-in log levels
# https://stackoverflow.com/a/28180781 | ||
echo "🟪 Cloning $GITHUB_REPOSITORY.wiki into $INPUT_PATH..." | ||
cd "$INPUT_PATH" | ||
gh repo clone "$GITHUB_REPOSITORY.wiki" .git -- --bare |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized that this could have a potential conflict with the documented usage to use path: .
, since a .git
directory will likely already exist at ./
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh shoot yeah
thats a problem when just plain git init
-ing or git clone --bare
-ing 😱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could use:
- GIT_DIR is the location of the .git folder. If this isn’t specified, Git walks up the directory tree until it gets to ~ or /, looking for a .git directory at every step.
- GIT_WORK_TREE is the location of the root of the working directory for a non-bare repository. If --git-dir or GIT_DIR is specified but none of --work-tree, GIT_WORK_TREE or core.worktree is specified, the current working directory is regarded as the top level of your working tree.
from https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables
and basically do
export GIT_DIR=../wiki.git
export GIT_WORK_TREE="$INPUT_PATH"
gh repo clone "$GITHUB_REPOSITORY" "$GIT_DIR" -- --bare
git config --unset core.bare
git reset
?? 🤔
echo "🟪 Cloning $GITHUB_REPOSITORY.wiki into $INPUT_PATH..." | ||
cd "$INPUT_PATH" | ||
gh repo clone "$GITHUB_REPOSITORY.wiki" .git -- --bare | ||
trap 'rm -rf .git' SIGINT SIGTERM ERR EXIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can just naively cleanup at the end without any "try-finally" behavior. The majority of workflows would stop if this action fails, which basically "cleans up," except possibly in a self-hosted runner. On failure, the .git
folder can continue to exist for the user's debug purposes.
closing in favor of more focused for things from #73 |
This PR would...
github-server-url
input optionrepository
to reflect that it's just user/repo nowx:$TOKEN
to just the defaultThis PR would also do
gh
CLI instead of plain gitGITHUB_*
env vars to override/replace those from https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables with the ones that the user wants (i.e. replace $GITHUB_TOKEN with $INPUT_TOKEN)GIT_*
env vars to override/setup git features as defined https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables>&2
stderr stuff when repo clone failsthese things were outside the scope of what i originally wanted to do, but just kinda happened as i made more changes...
using more $GITHUB_* env vars has the added benefit of interop-ing well with
gh
sincegh
sniffs$GITHUB_TOKEN
for its auth tokencloses #68
closes #67
closes #59 via using gh instead of rolling our own
closes #2 via using gh which handles that for us