Skip to content

Commit

Permalink
Add 'NO-PULL' feature (#150)
Browse files Browse the repository at this point in the history
* feat(pull_strategy): add `NO-PULL` option

* fix: add additional NO-PULL debug log
  • Loading branch information
EndBug committed Mar 3, 2021
1 parent 17b0915 commit f5554ef
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Add a step like this to your workflow:
# Default: 'Commit from GitHub Actions (name of the workflow)'
message: 'Your commit message'

# The flag used on the pull strategy
# The flag used on the pull strategy. Use NO-PULL to avoid the action pulling at all.
# Default: '--no-rebase'
pull_strategy: '--no-rebase or --no-ff or --rebase'
pull_strategy: 'NO-PULL or --no-rebase or --no-ff or --rebase'

# Whether to push the commit and, if any, its tags to the repo. It can also be used to set the git push arguments (see the paragraph below for more info)
# Default: true
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inputs:
description: The message for the commit
required: false
pull_strategy:
description: The flag used on the pull strategy
description: The flag used on the pull strategy. Use NO-PULL to avoid the action pulling at all.
required: false
default: '--no-rebase'
push:
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ console.log(`Running in ${baseDir}`)
.checkout(getInput('branch'), undefined, log)
.catch(() => git.checkoutLocalBranch(getInput('branch'), log))

info('> Pulling from remote...')
await git.fetch(undefined, log).pull(
undefined,
undefined,
{
[getInput('pull_strategy')]: null
},
log
)
if (getInput('pull_strategy') == 'NO-PULL') info('> Not pulling from repo.')
else {
info('> Pulling from remote...')
await git.fetch(undefined, log).pull(
undefined,
undefined,
{
[getInput('pull_strategy')]: null
},
log
)
}

info('> Re-staging files...')
if (getInput('add')) await add({ ignoreErrors: true })
Expand Down Expand Up @@ -257,6 +260,11 @@ async function checkInputs() {
}
// #endregion

// #region pull_strategy
if (getInput('pull_strategy') == 'NO-PULL')
debug("NO-PULL found: won't pull from remote.")
// #endregion

// #region push
if (getInput('push')) {
// It has to be either 'true', 'false', or any other string (use as arguments)
Expand Down

0 comments on commit f5554ef

Please sign in to comment.