Skip to content

Commit

Permalink
fix: remove all files in target directory
Browse files Browse the repository at this point in the history
  • Loading branch information
EndBug committed Sep 2, 2022
1 parent 021a6d0 commit 8637221
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions action.yml
Expand Up @@ -50,6 +50,7 @@ runs:
pr: ${{ github.event.number }}
actionref: ${{ github.action_ref }}
actionrepo: ${{ github.action_repository }}
worktree: pr-preview-action-temp-cleanup-folder
run: |
echo "action=$action" >> $GITHUB_ENV
echo "targetdir=$umbrella/pr-$pr" >> $GITHUB_ENV
Expand All @@ -64,6 +65,8 @@ runs:
echo "actionref=$actionref" >> $GITHUB_ENV
echo "actionrepo=$actionrepo" >> $GITHUB_ENV
echo "worktree=$worktree" >> $GITHUB_ENV
shell: bash

- name: Determine action version
Expand Down Expand Up @@ -108,18 +111,27 @@ runs:
at ${{ env.datetime }}
"

- name: Setup temp worktree
if: env.action == 'remove'
run: git worktree add ../$worktree
shell: bash

- name: Remove preview directory
if: env.action == 'remove'
uses: JamesIves/github-pages-deploy-action@v4
uses: EndBug/add-and-commit@v9
id: remove
with:
branch: ${{ inputs.preview-branch }}
folder: ${{ env.emptydir }}
target-folder: ${{ env.targetdir }}
commit-message: Remove preview for PR ${{ env.pr }} 🛬
force: false
cwd: ${{ env.worktree }}
remove: ${{ env.targetdir }} -r
message: Remove preview for PR ${{ env.pr }} 🛬

- name: Remove temp worktree
if: env.action == 'remove'
run: git worktree remove ../$worktree
shell: bash

- name: Leave a comment after removal
if: env.action == 'remove' && env.deployment_status == 'success'
if: env.action == 'remove'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
Expand Down

0 comments on commit 8637221

Please sign in to comment.