Skip to content

Commit

Permalink
Merge branch 'dev' into releases/v4
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Sep 29, 2024
2 parents 56d4ca7 + ff20230 commit fb1eb73
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,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
Expand Down
45 changes: 32 additions & 13 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -62,8 +51,8 @@ jobs:
uses: dawidd6/[email protected]
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
Expand All @@ -86,6 +75,7 @@ jobs:
uses: dawidd6/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: gh-pages

# Deploys using a container that requires you to install rsync.
integration-container:
Expand Down Expand Up @@ -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: [email protected]

- name: Cleanup Generated Branch
uses: dawidd6/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: gh-pages
6 changes: 6 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ jobs:
steps:
- uses: nowactions/[email protected]

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:
Expand Down
20 changes: 10 additions & 10 deletions __tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -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)
})
Expand All @@ -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)
})

Expand Down Expand Up @@ -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)
})

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
})
})
Expand All @@ -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)
})

Expand All @@ -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)
})
Expand All @@ -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)
})
Expand Down Expand Up @@ -466,7 +466,7 @@ describe('git', () => {
})

const response = await deploy(action)
expect(execute).toHaveBeenCalledTimes(16)
expect(execute).toHaveBeenCalledTimes(17)
expect(response).toBe(Status.SUCCESS)
})
})
Expand Down
4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> (https://jamesiv.es)",
"version": "4.6.5",
"version": "4.6.7",
"license": "MIT",
"main": "lib/lib.js",
"types": "lib/lib.d.ts",
Expand Down
15 changes: 14 additions & 1 deletion src/worktree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(
Expand Down

0 comments on commit fb1eb73

Please sign in to comment.