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 May 18, 2024
2 parents ec9c88b + 079c29c commit e9abb9c
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 244 deletions.
25 changes: 25 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ updates:
interval: daily
time: '10:00'
open-pull-requests-limit: 10
groups:
eslint:
patterns:
- 'eslint-*'
- '@typescript-eslint/*'
- '@eslint/*'

typescript:
patterns:
- 'typescript-*'
- '@typescript/*'

jest:
patterns:
- 'jest-*'
- '@jest/*'

actions:
patterns:
- 'actions/*'
- '@actions/*'

misc:
patterns:
- '*'

- package-ecosystem: github-actions
directory: '/'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'releases/v*'
push:
branches:
- 'dev*'
- '*'
tags-ignore:
- '*.*'
jobs:
Expand All @@ -32,7 +32,7 @@ jobs:
yarn test
- name: Uploade CodeCov Report
uses: codecov/codecov-action@v4.3.0
uses: codecov/codecov-action@v4.4.0
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ jobs:
needs: integration-ssh-third-party-client
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Build and Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down Expand Up @@ -309,6 +309,7 @@ jobs:
branch: gh-pages-rebase-conflict
folder: integration
force: false

# Clean up conflicting deployments
integration-rebase-conflicts-cleanup:
needs: [integration-rebase-conflicts-1, integration-rebase-conflicts-2]
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ Maintenance of this project is made possible by all the <a href="https://github.
</p>

<p align="center">
<!-- premium --><!-- premium -->
<!-- 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 -->
</p>

<p align="center">
<!-- 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 -->
<!-- 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 -->
</p>

## Getting Started :airplane:
Expand Down Expand Up @@ -80,6 +80,9 @@ jobs:
folder: build # The folder the action should deploy.
```

> [!NOTE]
> 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.
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.

```yml
Expand Down
14 changes: 7 additions & 7 deletions 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 <iam@jamesiv.es> (https://jamesiv.es)",
"version": "4.5.0",
"version": "4.6.0",
"license": "MIT",
"main": "lib/lib.js",
"types": "lib/lib.d.ts",
Expand Down Expand Up @@ -44,17 +44,17 @@
},
"devDependencies": {
"@types/jest": "29.5.12",
"@types/node": "20.12.7",
"@typescript-eslint/eslint-plugin": "7.7.0",
"@typescript-eslint/parser": "7.7.0",
"eslint": "9.0.0",
"@types/node": "20.12.12",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@typescript-eslint/parser": "7.9.0",
"eslint": "9.3.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.2.0",
"eslint-plugin-jest": "28.5.0",
"eslint-plugin-prettier": "5.1.3",
"jest": "29.7.0",
"jest-circus": "29.7.0",
"prettier": "3.2.5",
"rimraf": "5.0.5",
"rimraf": "5.0.7",
"ts-jest": "29.1.2",
"typescript": "5.4.5"
}
Expand Down
64 changes: 53 additions & 11 deletions src/worktree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,37 @@ import {ActionInterface} from './constants'
import {execute} from './execute'
import {extractErrorMessage, suppressSensitiveInformation} from './util'

/**
* Git checkout command.
*/
export class GitCheckout {
/**
* @param orphan - Bool indicating if the branch is an orphan.
*/
orphan = false

/**
* @param commitish - The commitish to check out.
*/
commitish?: string | null = null

/**
* @param branch - The branch name.
*/
branch: string
constructor(branch: string) {

/**
* @param branch - The branch name.
* @param commitish - The commitish to check out.
*/
constructor(branch: string, commitish?: string) {
this.branch = branch
this.commitish = commitish || null
}

/**
* Returns the string representation of the git checkout command.
*/
toString(): string {
return [
'git',
Expand All @@ -22,12 +46,15 @@ export class GitCheckout {
}

/**
* Generate the worktree and set initial content if it exists
* Generates a git worktree.
* @param action - The action interface.
* @param worktreedir - The worktree directory.
* @param branchExists - Bool indicating if the branch exists.
*/
export async function generateWorktree(
action: ActionInterface,
worktreedir: string,
branchExists: unknown
branchExists: boolean | number
): Promise<void> {
try {
info('Creating worktree…')
Expand All @@ -46,7 +73,8 @@ export async function generateWorktree(
action.silent
)

const checkout = new GitCheckout(action.branch)
let branchName = action.branch
let checkout = new GitCheckout(branchName)

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

await execute(
checkout.toString(),
`${action.workspace}/${worktreedir}`,
action.silent
)
try {
await execute(
checkout.toString(),
`${action.workspace}/${worktreedir}`,
action.silent
)
} catch (error) {
info(
'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}`)

await execute(
checkout.toString(),
`${action.workspace}/${worktreedir}`,
action.silent
)
}

if (!branchExists) {
info(`Created the ${action.branch} branch… 🔧`)
info(`Created the ${branchName} branch… 🔧`)

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

0 comments on commit e9abb9c

Please sign in to comment.