Skip to content

Commit 8eedda6

Browse files
RomanHotsiypeaceiris
authored andcommitted
feat: new option keepFiles (#33)
1 parent 13d6946 commit 8eedda6

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,23 @@ For example:
199199
emptyCommits: false
200200
```
201201

202+
#### ⭐️ Keeping existing files
203+
204+
By default, existing files in the publish branch are removed before adding the ones from publish dir. If you want the action to add new files but leave existing ones untouched, set the optional parameter `keepFiles` to `true`.
205+
206+
For example:
207+
208+
```yaml
209+
- name: deploy
210+
uses: peaceiris/[email protected]
211+
env:
212+
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
213+
PUBLISH_BRANCH: gh-pages
214+
PUBLISH_DIR: ./public
215+
with:
216+
keepFiles: true
217+
```
218+
202219

203220
## Tips and FAQ
204221

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ inputs:
1212
description: 'If empty commits should be made to the publication branch'
1313
required: false
1414
default: 'true'
15+
keepFiles:
16+
description: 'If existing files in the publish branch should be not removed before deploying'
17+
required: false
18+
default: 'false'

entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ remote_branch="${PUBLISH_BRANCH}"
6161
local_dir="${HOME}/$(tr -cd 'a-f0-9' < /dev/urandom | head -c 32)"
6262
if git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
6363
cd "${local_dir}"
64-
git rm -r --ignore-unmatch '*'
64+
65+
print_info "Keeping existing files: ${INPUT_KEEPFILES}"
66+
if [[ ${INPUT_KEEPFILES} != "true" ]]; then
67+
git rm -r --ignore-unmatch '*'
68+
fi
69+
6570
find "${GITHUB_WORKSPACE}/${PUBLISH_DIR}" -maxdepth 1 | \
6671
tail -n +2 | \
6772
xargs -I % cp -rf % "${local_dir}/"

0 commit comments

Comments
 (0)