diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa06d99aa..a3398dfa9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -113,7 +113,8 @@ jobs: - name: Tweak content to publish to existing branch if: ${{ matrix.branch == 'gh-pages' }} run: | - echo "" >> integration/index.html + RANDOM_CHAR=$(echo $RANDOM | tr -dc 'a-zA-Z0-9' | fold -w 1 | head -n 1) + echo "" >> integration/index.html - name: Deploy with modifications to existing branch id: modified diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 07b5bcfc3..eba9e5d4b 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,7 @@ jobs: 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: @@ -340,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 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: 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/package.json b/package.json index 7e49b427d..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 (https://jamesiv.es)", - "version": "4.6.5", + "version": "4.6.7", "license": "MIT", "main": "lib/lib.js", "types": "lib/lib.d.ts", diff --git a/src/worktree.ts b/src/worktree.ts index 5b337bcce..ec94670c6 100644 --- a/src/worktree.ts +++ b/src/worktree.ts @@ -101,7 +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 = new GitCheckout(branchName, `origin/${action.branch}`) + checkout = new GitCheckout(branchName) await execute( checkout.toString(), @@ -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(