Skip to content

Commit 8637221

Browse files
authored
fix: remove all files in target directory
Closes rossjrw#15 Related future improvements: JamesIves/github-pages-deploy-action#1210 EndBug/add-and-commit#429
1 parent 021a6d0 commit 8637221

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

action.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ runs:
5050
pr: ${{ github.event.number }}
5151
actionref: ${{ github.action_ref }}
5252
actionrepo: ${{ github.action_repository }}
53+
worktree: pr-preview-action-temp-cleanup-folder
5354
run: |
5455
echo "action=$action" >> $GITHUB_ENV
5556
echo "targetdir=$umbrella/pr-$pr" >> $GITHUB_ENV
@@ -64,6 +65,8 @@ runs:
6465
6566
echo "actionref=$actionref" >> $GITHUB_ENV
6667
echo "actionrepo=$actionrepo" >> $GITHUB_ENV
68+
69+
echo "worktree=$worktree" >> $GITHUB_ENV
6770
shell: bash
6871

6972
- name: Determine action version
@@ -108,18 +111,27 @@ runs:
108111
at ${{ env.datetime }}
109112
"
110113

114+
- name: Setup temp worktree
115+
if: env.action == 'remove'
116+
run: git worktree add ../$worktree
117+
shell: bash
118+
111119
- name: Remove preview directory
112120
if: env.action == 'remove'
113-
uses: JamesIves/github-pages-deploy-action@v4
121+
uses: EndBug/add-and-commit@v9
122+
id: remove
114123
with:
115-
branch: ${{ inputs.preview-branch }}
116-
folder: ${{ env.emptydir }}
117-
target-folder: ${{ env.targetdir }}
118-
commit-message: Remove preview for PR ${{ env.pr }} 🛬
119-
force: false
124+
cwd: ${{ env.worktree }}
125+
remove: ${{ env.targetdir }} -r
126+
message: Remove preview for PR ${{ env.pr }} 🛬
127+
128+
- name: Remove temp worktree
129+
if: env.action == 'remove'
130+
run: git worktree remove ../$worktree
131+
shell: bash
120132

121133
- name: Leave a comment after removal
122-
if: env.action == 'remove' && env.deployment_status == 'success'
134+
if: env.action == 'remove'
123135
uses: marocchino/sticky-pull-request-comment@v2
124136
with:
125137
header: pr-preview

0 commit comments

Comments
 (0)