Skip to content

Commit e9abb9c

Browse files
committed
Merge branch 'dev' into releases/v4
2 parents ec9c88b + 079c29c commit e9abb9c

File tree

7 files changed

+227
-244
lines changed

7 files changed

+227
-244
lines changed

.github/dependabot.yml

+25
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ updates:
66
interval: daily
77
time: '10:00'
88
open-pull-requests-limit: 10
9+
groups:
10+
eslint:
11+
patterns:
12+
- 'eslint-*'
13+
- '@typescript-eslint/*'
14+
- '@eslint/*'
15+
16+
typescript:
17+
patterns:
18+
- 'typescript-*'
19+
- '@typescript/*'
20+
21+
jest:
22+
patterns:
23+
- 'jest-*'
24+
- '@jest/*'
25+
26+
actions:
27+
patterns:
28+
- 'actions/*'
29+
- '@actions/*'
30+
31+
misc:
32+
patterns:
33+
- '*'
934

1035
- package-ecosystem: github-actions
1136
directory: '/'

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- 'releases/v*'
77
push:
88
branches:
9-
- 'dev*'
9+
- '*'
1010
tags-ignore:
1111
- '*.*'
1212
jobs:
@@ -32,7 +32,7 @@ jobs:
3232
yarn test
3333
3434
- name: Uploade CodeCov Report
35-
uses: codecov/codecov-action@v4.3.0
35+
uses: codecov/codecov-action@v4.4.0
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838

.github/workflows/integration.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ jobs:
173173
needs: integration-ssh-third-party-client
174174
runs-on: ubuntu-latest
175175
steps:
176-
- uses: actions/setup-node@v4
177-
with:
178-
node-version-file: '.nvmrc'
179-
180176
- name: Checkout
181177
uses: actions/checkout@v4
182178
with:
183179
persist-credentials: false
184180

181+
- uses: actions/setup-node@v4
182+
with:
183+
node-version-file: '.nvmrc'
184+
185185
- name: Build and Deploy
186186
uses: JamesIves/github-pages-deploy-action@v4
187187
with:
@@ -309,6 +309,7 @@ jobs:
309309
branch: gh-pages-rebase-conflict
310310
folder: integration
311311
force: false
312+
312313
# Clean up conflicting deployments
313314
integration-rebase-conflicts-cleanup:
314315
needs: [integration-rebase-conflicts-1, integration-rebase-conflicts-2]

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ Maintenance of this project is made possible by all the <a href="https://github.
4343
</p>
4444

4545
<p align="center">
46-
<!-- premium --><!-- premium -->
46+
<!-- premium --><a href="https://github.com/github"><img src="https://github.com/github.png" width="80px" alt="github" /></a>&nbsp;&nbsp;<a href="https://github.com/annegentle"><img src="https://github.com/annegentle.png" width="80px" alt="annegentle" /></a>&nbsp;&nbsp;<!-- premium -->
4747
</p>
4848

4949
<p align="center">
50-
<!-- sponsors --><a href="https://github.com/Chooksta69"><img src="https://github.com/Chooksta69.png" width="50px" alt="Chooksta69" /></a>&nbsp;&nbsp;<a href="https://github.com/robjtede"><img src="https://github.com/robjtede.png" width="50px" alt="robjtede" /></a>&nbsp;&nbsp;<a href="https://github.com/hadley"><img src="https://github.com/hadley.png" width="50px" alt="hadley" /></a>&nbsp;&nbsp;<a href="https://github.com/kevinchalet"><img src="https://github.com/kevinchalet.png" width="50px" alt="kevinchalet" /></a>&nbsp;&nbsp;<a href="https://github.com/sckott"><img src="https://github.com/sckott.png" width="50px" alt="sckott" /></a>&nbsp;&nbsp;<a href="https://github.com/electrovir"><img src="https://github.com/electrovir.png" width="50px" alt="electrovir" /></a>&nbsp;&nbsp;<!-- sponsors -->
50+
<!-- sponsors --><a href="https://github.com/Chooksta69"><img src="https://github.com/Chooksta69.png" width="50px" alt="Chooksta69" /></a>&nbsp;&nbsp;<a href="https://github.com/MattWillFlood"><img src="https://github.com/MattWillFlood.png" width="50px" alt="MattWillFlood" /></a>&nbsp;&nbsp;<a href="https://github.com/jonathan-milan-pollock"><img src="https://github.com/jonathan-milan-pollock.png" width="50px" alt="jonathan-milan-pollock" /></a>&nbsp;&nbsp;<a href="https://github.com/raoulvdberge"><img src="https://github.com/raoulvdberge.png" width="50px" alt="raoulvdberge" /></a>&nbsp;&nbsp;<a href="https://github.com/robjtede"><img src="https://github.com/robjtede.png" width="50px" alt="robjtede" /></a>&nbsp;&nbsp;<a href="https://github.com/hadley"><img src="https://github.com/hadley.png" width="50px" alt="hadley" /></a>&nbsp;&nbsp;<a href="https://github.com/kevinchalet"><img src="https://github.com/kevinchalet.png" width="50px" alt="kevinchalet" /></a>&nbsp;&nbsp;<a href="https://github.com/Yousazoe"><img src="https://github.com/Yousazoe.png" width="50px" alt="Yousazoe" /></a>&nbsp;&nbsp;<a href="https://github.com/planetoftheweb"><img src="https://github.com/planetoftheweb.png" width="50px" alt="planetoftheweb" /></a>&nbsp;&nbsp;<a href="https://github.com/melton1968"><img src="https://github.com/melton1968.png" width="50px" alt="melton1968" /></a>&nbsp;&nbsp;<a href="https://github.com/szepeviktor"><img src="https://github.com/szepeviktor.png" width="50px" alt="szepeviktor" /></a>&nbsp;&nbsp;<a href="https://github.com/sckott"><img src="https://github.com/sckott.png" width="50px" alt="sckott" /></a>&nbsp;&nbsp;<a href="https://github.com/provinzkraut"><img src="https://github.com/provinzkraut.png" width="50px" alt="provinzkraut" /></a>&nbsp;&nbsp;<a href="https://github.com/electrovir"><img src="https://github.com/electrovir.png" width="50px" alt="electrovir" /></a>&nbsp;&nbsp;<a href="https://github.com/Griefed"><img src="https://github.com/Griefed.png" width="50px" alt="Griefed" /></a>&nbsp;&nbsp;<!-- sponsors -->
5151
</p>
5252

5353
## Getting Started :airplane:
@@ -80,6 +80,9 @@ jobs:
8080
folder: build # The folder the action should deploy.
8181
```
8282
83+
> [!NOTE]
84+
> You must configure your repository to deploy from the branch you push to. To do this, go to your repository settings, click on `Pages`, and choose `Deploy from a Branch` from the `Source` dropdown. From there select the branch you supplied to the action. In most cases this will be `gh-pages` as that's the default.
85+
8386
If you'd like to make it so the workflow only triggers on push events to specific branches then you can modify the `on` section.
8487

8588
```yml

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@jamesives/github-pages-deploy-action",
33
"description": "GitHub action for building a project and deploying it to GitHub pages.",
44
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
5-
"version": "4.5.0",
5+
"version": "4.6.0",
66
"license": "MIT",
77
"main": "lib/lib.js",
88
"types": "lib/lib.d.ts",
@@ -44,17 +44,17 @@
4444
},
4545
"devDependencies": {
4646
"@types/jest": "29.5.12",
47-
"@types/node": "20.12.7",
48-
"@typescript-eslint/eslint-plugin": "7.7.0",
49-
"@typescript-eslint/parser": "7.7.0",
50-
"eslint": "9.0.0",
47+
"@types/node": "20.12.12",
48+
"@typescript-eslint/eslint-plugin": "7.9.0",
49+
"@typescript-eslint/parser": "7.9.0",
50+
"eslint": "9.3.0",
5151
"eslint-config-prettier": "9.1.0",
52-
"eslint-plugin-jest": "28.2.0",
52+
"eslint-plugin-jest": "28.5.0",
5353
"eslint-plugin-prettier": "5.1.3",
5454
"jest": "29.7.0",
5555
"jest-circus": "29.7.0",
5656
"prettier": "3.2.5",
57-
"rimraf": "5.0.5",
57+
"rimraf": "5.0.7",
5858
"ts-jest": "29.1.2",
5959
"typescript": "5.4.5"
6060
}

src/worktree.ts

+53-11
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,37 @@ import {ActionInterface} from './constants'
33
import {execute} from './execute'
44
import {extractErrorMessage, suppressSensitiveInformation} from './util'
55

6+
/**
7+
* Git checkout command.
8+
*/
69
export class GitCheckout {
10+
/**
11+
* @param orphan - Bool indicating if the branch is an orphan.
12+
*/
713
orphan = false
14+
15+
/**
16+
* @param commitish - The commitish to check out.
17+
*/
818
commitish?: string | null = null
19+
20+
/**
21+
* @param branch - The branch name.
22+
*/
923
branch: string
10-
constructor(branch: string) {
24+
25+
/**
26+
* @param branch - The branch name.
27+
* @param commitish - The commitish to check out.
28+
*/
29+
constructor(branch: string, commitish?: string) {
1130
this.branch = branch
31+
this.commitish = commitish || null
1232
}
33+
34+
/**
35+
* Returns the string representation of the git checkout command.
36+
*/
1337
toString(): string {
1438
return [
1539
'git',
@@ -22,12 +46,15 @@ export class GitCheckout {
2246
}
2347

2448
/**
25-
* Generate the worktree and set initial content if it exists
49+
* Generates a git worktree.
50+
* @param action - The action interface.
51+
* @param worktreedir - The worktree directory.
52+
* @param branchExists - Bool indicating if the branch exists.
2653
*/
2754
export async function generateWorktree(
2855
action: ActionInterface,
2956
worktreedir: string,
30-
branchExists: unknown
57+
branchExists: boolean | number
3158
): Promise<void> {
3259
try {
3360
info('Creating worktree…')
@@ -46,7 +73,8 @@ export async function generateWorktree(
4673
action.silent
4774
)
4875

49-
const checkout = new GitCheckout(action.branch)
76+
let branchName = action.branch
77+
let checkout = new GitCheckout(branchName)
5078

5179
if (branchExists) {
5280
// There's existing data on the branch to check out
@@ -62,14 +90,28 @@ export async function generateWorktree(
6290
checkout.orphan = true
6391
}
6492

65-
await execute(
66-
checkout.toString(),
67-
`${action.workspace}/${worktreedir}`,
68-
action.silent
69-
)
93+
try {
94+
await execute(
95+
checkout.toString(),
96+
`${action.workspace}/${worktreedir}`,
97+
action.silent
98+
)
99+
} catch (error) {
100+
info(
101+
'Error encountered while checking out branch. Attempting to continue with a new branch name.'
102+
)
103+
branchName = `temp-${Date.now()}`
104+
checkout = new GitCheckout(branchName, `origin/${action.branch}`)
105+
106+
await execute(
107+
checkout.toString(),
108+
`${action.workspace}/${worktreedir}`,
109+
action.silent
110+
)
111+
}
70112

71113
if (!branchExists) {
72-
info(`Created the ${action.branch} branch… 🔧`)
114+
info(`Created the ${branchName} branch… 🔧`)
73115

74116
// Our index is in HEAD state, reset
75117
await execute(
@@ -81,7 +123,7 @@ export async function generateWorktree(
81123
if (!action.singleCommit) {
82124
// New history isn't singleCommit, create empty initial commit
83125
await execute(
84-
`git commit --no-verify --allow-empty -m "Initial ${action.branch} commit"`,
126+
`git commit --no-verify --allow-empty -m "Initial ${branchName} commit"`,
85127
`${action.workspace}/${worktreedir}`,
86128
action.silent
87129
)

0 commit comments

Comments
 (0)