From 1613689878bd87ba5a9e93687f24509a6eb3349e Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Fri, 27 Sep 2024 17:13:36 +0000
Subject: [PATCH 01/10] =?UTF-8?q?Release=204.6.6=20=F0=9F=93=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package.json b/package.json
index 7e49b427d..3f80d52a9 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
   "name": "@jamesives/github-pages-deploy-action",
   "description": "GitHub action for building a project and deploying it to GitHub pages.",
   "author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
-  "version": "4.6.5",
+  "version": "4.6.6",
   "license": "MIT",
   "main": "lib/lib.js",
   "types": "lib/lib.d.ts",

From a86ae7a98f0d7580d63eb96abd48747bf8bdcefe Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sat, 28 Sep 2024 11:46:50 +0000
Subject: [PATCH 02/10] =?UTF-8?q?Release=204.6.7=20=F0=9F=93=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package.json b/package.json
index 3f80d52a9..73529c674 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
   "name": "@jamesives/github-pages-deploy-action",
   "description": "GitHub action for building a project and deploying it to GitHub pages.",
   "author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
-  "version": "4.6.6",
+  "version": "4.6.7",
   "license": "MIT",
   "main": "lib/lib.js",
   "types": "lib/lib.d.ts",

From e3d934700ed5ebf3654de3fbcaec5ff50a236a3e Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sat, 28 Sep 2024 14:04:05 -0400
Subject: [PATCH 03/10] =?UTF-8?q?test:=20=F0=9F=A7=AA=20=20improve=20integ?=
 =?UTF-8?q?ration=20test=20workflow=20order=20(#1700)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* test: improve integration test workflow

* Update integration.yml

* Update version.yml

* test: tidy up integration tests
---
 .github/workflows/integration.yml | 45 ++++++++++++++++++++++---------
 .github/workflows/version.yml     |  6 +++++
 2 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 07b5bcfc3..79b5077c5 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -1,21 +1,11 @@
 name: Integration Tests 🧪
 on:
+  workflow_call:
   workflow_dispatch:
-    inputs:
-      branch:
-        description: 'Specifies the branch which the integration tests should run on.'
-        required: true
-        default: 'releases/v4'
   schedule:
     - cron: 30 15 * * 0-6
-  push:
-    tags-ignore:
-      - '*.*'
-    branches:
-      - releases/v4
 
 jobs:
-  # Deploys cross repo with an access token.
   integration-cross-repo-push:
     container: node:16.13
     runs-on: ubuntu-latest
@@ -40,7 +30,6 @@ jobs:
           clean: true
           silent: true
 
-  # Deploys using checkout@v1 with an ACCESS_TOKEN.
   integration-checkout-v1:
     needs: integration-cross-repo-push
     runs-on: ubuntu-latest
@@ -62,8 +51,8 @@ jobs:
         uses: dawidd6/action-delete-branch@v3.1.0
         with:
           github_token: ${{ secrets.GITHUB_TOKEN }}
+          branches: gh-pages
 
-  # Deploys using checkout@v2 with a GITHUB_TOKEN.
   integration-checkout-v2:
     needs: integration-checkout-v1
     runs-on: ubuntu-latest
@@ -86,6 +75,36 @@ jobs:
         uses: dawidd6/action-delete-branch@v3.1.0
         with:
           github_token: ${{ secrets.GITHUB_TOKEN }}
+          branches: gh-pages
+
+  integration-root-folder:
+    needs: integration-checkout-v1
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+        with:
+          persist-credentials: false
+
+      - name: Echo
+        working-directory: integration
+        run: |
+          echo "Here"
+
+      - name: Build and Deploy
+        uses: JamesIves/github-pages-deploy-action@v4
+        with:
+          folder: .
+          target-folder: cat/montezuma5
+          silent: true
+          git-config-name: Montezuma
+          git-config-email: montezuma@jamesiv.es
+
+      - name: Cleanup Generated Branch
+        uses: dawidd6/action-delete-branch@v3.1.0
+        with:
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          branches: gh-pages
 
   # Deploys using a container that requires you to install rsync.
   integration-container:
diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml
index 3586e735e..231329483 100644
--- a/.github/workflows/version.yml
+++ b/.github/workflows/version.yml
@@ -12,7 +12,13 @@ jobs:
     steps:
       - uses: nowactions/update-majorver@v1.1.2
 
+  call-integration-workflow:
+    name: Verify Major Tag 🚀
+    needs: update-majorver
+    uses: ./.github/workflows/integration.yml
+
   update-registries:
+    needs: call-integration-workflow
     name: Publish to Registries 📦
     runs-on: ubuntu-latest
     steps:

From b1825434e4776203996283faae391daad2ec0aab Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sat, 28 Sep 2024 14:12:55 -0400
Subject: [PATCH 04/10] build: move int test

---
 .github/workflows/integration.yml | 58 +++++++++++++++----------------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 79b5077c5..eba9e5d4b 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -77,35 +77,6 @@ jobs:
           github_token: ${{ secrets.GITHUB_TOKEN }}
           branches: gh-pages
 
-  integration-root-folder:
-    needs: integration-checkout-v1
-    runs-on: ubuntu-latest
-    steps:
-      - name: Checkout
-        uses: actions/checkout@v4
-        with:
-          persist-credentials: false
-
-      - name: Echo
-        working-directory: integration
-        run: |
-          echo "Here"
-
-      - name: Build and Deploy
-        uses: JamesIves/github-pages-deploy-action@v4
-        with:
-          folder: .
-          target-folder: cat/montezuma5
-          silent: true
-          git-config-name: Montezuma
-          git-config-email: montezuma@jamesiv.es
-
-      - name: Cleanup Generated Branch
-        uses: dawidd6/action-delete-branch@v3.1.0
-        with:
-          github_token: ${{ secrets.GITHUB_TOKEN }}
-          branches: gh-pages
-
   # Deploys using a container that requires you to install rsync.
   integration-container:
     needs: integration-checkout-v2
@@ -359,3 +330,32 @@ jobs:
           owner: MontezumaIves
           repository: lab
           branches: gh-pages
+
+  integration-root-folder:
+    needs: integration-rebase-conflicts-cleanup
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+        with:
+          persist-credentials: false
+
+      - name: Echo
+        working-directory: integration
+        run: |
+          echo "Here"
+
+      - name: Build and Deploy
+        uses: JamesIves/github-pages-deploy-action@v4
+        with:
+          folder: .
+          target-folder: cat/montezuma5
+          silent: true
+          git-config-name: Montezuma
+          git-config-email: montezuma@jamesiv.es
+
+      - name: Cleanup Generated Branch
+        uses: dawidd6/action-delete-branch@v3.1.0
+        with:
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          branches: gh-pages

From 74a410d06e43924779dfeef258f6eb491b77ddff Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sat, 28 Sep 2024 15:47:02 -0400
Subject: [PATCH 05/10] fix: :bug: Add the temp directory created to the safe
 directory list (#1701)

---
 __tests__/git.test.ts  | 20 ++++++++++----------
 __tests__/main.test.ts |  4 ++--
 src/worktree.ts        | 13 +++++++++++++
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts
index ddb0b65d2..e7b76c1d8 100644
--- a/__tests__/git.test.ts
+++ b/__tests__/git.test.ts
@@ -167,7 +167,7 @@ describe('git', () => {
       const response = await deploy(action)
 
       // Includes the call to generateWorktree
-      expect(execute).toHaveBeenCalledTimes(14)
+      expect(execute).toHaveBeenCalledTimes(15)
       expect(rmRF).toHaveBeenCalledTimes(1)
       expect(response).toBe(Status.SUCCESS)
     })
@@ -190,7 +190,7 @@ describe('git', () => {
       const response = await deploy(action)
 
       // Includes the call to generateWorktree
-      expect(execute).toHaveBeenCalledTimes(13)
+      expect(execute).toHaveBeenCalledTimes(14)
       expect(rmRF).toHaveBeenCalledTimes(1)
       expect(response).toBe(Status.SUCCESS)
     })
@@ -215,7 +215,7 @@ describe('git', () => {
       await deploy(action)
 
       // Includes the call to generateWorktree
-      expect(execute).toHaveBeenCalledTimes(14)
+      expect(execute).toHaveBeenCalledTimes(15)
       expect(rmRF).toHaveBeenCalledTimes(1)
     })
 
@@ -264,7 +264,7 @@ describe('git', () => {
       await deploy(action)
 
       // Includes the call to generateWorktree
-      expect(execute).toHaveBeenCalledTimes(13)
+      expect(execute).toHaveBeenCalledTimes(14)
       expect(rmRF).toHaveBeenCalledTimes(1)
     })
 
@@ -295,7 +295,7 @@ describe('git', () => {
       const response = await deploy(action)
 
       // Includes the call to generateWorktree
-      expect(execute).toHaveBeenCalledTimes(14)
+      expect(execute).toHaveBeenCalledTimes(15)
       expect(rmRF).toHaveBeenCalledTimes(1)
       expect(fs.existsSync).toHaveBeenCalledTimes(2)
       expect(response).toBe(Status.SUCCESS)
@@ -327,7 +327,7 @@ describe('git', () => {
         await deploy(action)
 
         // Includes the call to generateWorktree
-        expect(execute).toHaveBeenCalledTimes(11)
+        expect(execute).toHaveBeenCalledTimes(12)
         expect(rmRF).toHaveBeenCalledTimes(1)
       })
     })
@@ -352,7 +352,7 @@ describe('git', () => {
       await deploy(action)
 
       // Includes the call to generateWorktree
-      expect(execute).toHaveBeenCalledTimes(11)
+      expect(execute).toHaveBeenCalledTimes(12)
       expect(rmRF).toHaveBeenCalledTimes(1)
     })
 
@@ -372,7 +372,7 @@ describe('git', () => {
 
       await deploy(action)
 
-      expect(execute).toHaveBeenCalledTimes(11)
+      expect(execute).toHaveBeenCalledTimes(12)
       expect(rmRF).toHaveBeenCalledTimes(1)
       expect(mkdirP).toHaveBeenCalledTimes(1)
     })
@@ -392,7 +392,7 @@ describe('git', () => {
       })
 
       const response = await deploy(action)
-      expect(execute).toHaveBeenCalledTimes(11)
+      expect(execute).toHaveBeenCalledTimes(12)
       expect(rmRF).toHaveBeenCalledTimes(1)
       expect(response).toBe(Status.SKIPPED)
     })
@@ -466,7 +466,7 @@ describe('git', () => {
       })
 
       const response = await deploy(action)
-      expect(execute).toHaveBeenCalledTimes(16)
+      expect(execute).toHaveBeenCalledTimes(17)
       expect(response).toBe(Status.SUCCESS)
     })
   })
diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts
index f0ec58053..3d33495aa 100644
--- a/__tests__/main.test.ts
+++ b/__tests__/main.test.ts
@@ -53,7 +53,7 @@ describe('main', () => {
       debug: true
     })
     await run(action)
-    expect(execute).toHaveBeenCalledTimes(18)
+    expect(execute).toHaveBeenCalledTimes(19)
     expect(rmRF).toHaveBeenCalledTimes(1)
     expect(exportVariable).toHaveBeenCalledTimes(1)
   })
@@ -73,7 +73,7 @@ describe('main', () => {
       isTest: TestFlag.HAS_CHANGED_FILES
     })
     await run(action)
-    expect(execute).toHaveBeenCalledTimes(21)
+    expect(execute).toHaveBeenCalledTimes(22)
     expect(rmRF).toHaveBeenCalledTimes(1)
     expect(exportVariable).toHaveBeenCalledTimes(1)
   })
diff --git a/src/worktree.ts b/src/worktree.ts
index 5b337bcce..ceeebb69e 100644
--- a/src/worktree.ts
+++ b/src/worktree.ts
@@ -128,6 +128,19 @@ export async function generateWorktree(
           action.silent
         )
       }
+
+      /**
+       * Ensure that the workspace is a safe directory.
+       */
+      try {
+        await execute(
+          `git config --global --add safe.directory "${action.workspace}/${worktreedir}"`,
+          action.workspace,
+          action.silent
+        )
+      } catch {
+        info('Unable to set worktree temp directory as a safe directory…')
+      }
     }
   } catch (error) {
     throw new Error(

From e6e8596e8bc8d22a08a6aab1c15df59ef4b33fcb Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sat, 28 Sep 2024 15:50:08 -0400
Subject: [PATCH 06/10] Update build.yml

---
 .github/workflows/build.yml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index aa06d99aa..0352fb3ca 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -67,6 +67,12 @@ jobs:
           path: |
             lib
             node_modules
+        
+      - name: Cleanup Generated Branches
+        uses: dawidd6/action-delete-branch@v3.1.0
+        with:
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          branches: gh-pages
 
   integration:
     runs-on: ubuntu-latest

From ca05c362afa27159ef050ea15e379bef71256eb1 Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sat, 28 Sep 2024 15:51:59 -0400
Subject: [PATCH 07/10] Update build.yml

---
 .github/workflows/build.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0352fb3ca..23ab6ddd6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -70,6 +70,7 @@ jobs:
         
       - name: Cleanup Generated Branches
         uses: dawidd6/action-delete-branch@v3.1.0
+        continue-on-error: true
         with:
           github_token: ${{ secrets.GITHUB_TOKEN }}
           branches: gh-pages

From 78ce9cd1cd0acdd836e2634b4490264d0d63b06c Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sat, 28 Sep 2024 15:54:34 -0400
Subject: [PATCH 08/10] Update build.yml

---
 .github/workflows/build.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 23ab6ddd6..4dcc8676f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -67,7 +67,7 @@ jobs:
           path: |
             lib
             node_modules
-        
+
       - name: Cleanup Generated Branches
         uses: dawidd6/action-delete-branch@v3.1.0
         continue-on-error: true

From b06fcc88f913742371f1ce876e804fe609ba9130 Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sat, 28 Sep 2024 16:03:27 -0400
Subject: [PATCH 09/10] fix: make the temp branch an orphan

---
 src/worktree.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/worktree.ts b/src/worktree.ts
index ceeebb69e..7a7589cd0 100644
--- a/src/worktree.ts
+++ b/src/worktree.ts
@@ -101,6 +101,7 @@ export async function generateWorktree(
         'Error encountered while checking out branch. Attempting to continue with a new branch name.'
       )
       branchName = `temp-${Date.now()}`
+      checkout.orphan = true
       checkout = new GitCheckout(branchName, `origin/${action.branch}`)
 
       await execute(

From ff20230deef023e9c51970348365b821371aa108 Mon Sep 17 00:00:00 2001
From: James Ives <iam@jamesiv.es>
Date: Sun, 29 Sep 2024 10:55:01 -0400
Subject: [PATCH 10/10] fix: resolve 'origin/gh-pages' is not a commit and a
 branch cannot be created from it error (#1702)

* fix: orphan branch issue

* Update worktree.ts

* Update worktree.ts

* Update worktree.ts

* Update worktree.ts

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml
---
 .github/workflows/build.yml | 10 ++--------
 src/worktree.ts             |  3 +--
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4dcc8676f..a3398dfa9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -68,13 +68,6 @@ jobs:
             lib
             node_modules
 
-      - name: Cleanup Generated Branches
-        uses: dawidd6/action-delete-branch@v3.1.0
-        continue-on-error: true
-        with:
-          github_token: ${{ secrets.GITHUB_TOKEN }}
-          branches: gh-pages
-
   integration:
     runs-on: ubuntu-latest
     needs: build
@@ -120,7 +113,8 @@ jobs:
       - name: Tweak content to publish to existing branch
         if: ${{ matrix.branch == 'gh-pages' }}
         run: |
-          echo "<!-- just sayin -->" >> integration/index.html
+          RANDOM_CHAR=$(echo $RANDOM | tr -dc 'a-zA-Z0-9' | fold -w 1 | head -n 1)
+          echo "<!-- just sayin $RANDOM_CHAR -->" >> integration/index.html
 
       - name: Deploy with modifications to existing branch
         id: modified
diff --git a/src/worktree.ts b/src/worktree.ts
index 7a7589cd0..ec94670c6 100644
--- a/src/worktree.ts
+++ b/src/worktree.ts
@@ -101,8 +101,7 @@ export async function generateWorktree(
         'Error encountered while checking out branch. Attempting to continue with a new branch name.'
       )
       branchName = `temp-${Date.now()}`
-      checkout.orphan = true
-      checkout = new GitCheckout(branchName, `origin/${action.branch}`)
+      checkout = new GitCheckout(branchName)
 
       await execute(
         checkout.toString(),