diff --git a/.github/workflows/cd_pipeline.yml b/.github/workflows/cd_pipeline.yml index 8a05663..62a1cac 100644 --- a/.github/workflows/cd_pipeline.yml +++ b/.github/workflows/cd_pipeline.yml @@ -27,8 +27,13 @@ jobs: - name: Clear git worktree before deployment run: | git worktree prune - if [ -d "github-pages-deploy-action-temp-deployment-folder" ]; then - rm -rf github-pages-deploy-action-temp-deployment-folder + if git worktree list | grep -q 'github-pages-deploy-action-temp-deployment-folder'; then + echo "Removing existing temp deployment folder" + git worktree remove github-pages-deploy-action-temp-deployment-folder --force + fi + if git worktree list | grep -q '\[main\]'; then + echo "Removing existing main worktree" + git worktree remove $(git worktree list | grep '\[main\]' | awk '{print $1}') --force fi - name: Download a Build Artifact Version uses: dawidd6/action-download-artifact@v2.26.1 @@ -67,7 +72,10 @@ jobs: echo "Removing existing temp deployment folder" git worktree remove github-pages-deploy-action-temp-deployment-folder --force fi - + if git worktree list | grep -q '\[main\]'; then + echo "Removing existing main worktree" + git worktree remove $(git worktree list | grep '\[main\]' | awk '{print $1}') --force + fi - name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4.4.0 @@ -78,3 +86,9 @@ jobs: repository-name: CIROH-UA/ciroh-ua.github.io #tag: $VERSION + - name: Final cleanup + run: | + git worktree prune + if [ -d "github-pages-deploy-action-temp-deployment-folder" ]; then + rm -rf github-pages-deploy-action-temp-deployment-folder + fi