github-pages-deploy-action
Advanced tools
Comparing version 3.4.9 to 3.4.10
@@ -91,6 +91,25 @@ // Initial env variable setup for tests. | ||
email: 'as@cat' | ||
} | ||
}) | ||
try { | ||
await init(action) | ||
} catch (e) { | ||
expect(execute).toBeCalledTimes(0) | ||
expect(e.message).toMatch( | ||
'There was an error initializing the repository: No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true. ❌' | ||
) | ||
} | ||
}) | ||
it('should fail if access token is defined but it is an empty string', async () => { | ||
Object.assign(action, { | ||
repositoryPath: null, | ||
folder: 'build', | ||
branch: 'branch', | ||
pusher: { | ||
name: 'asd', | ||
email: 'as@cat' | ||
}, | ||
gitHubToken: null, | ||
accessToken: null, | ||
ssh: null | ||
accessToken: '' | ||
}) | ||
@@ -97,0 +116,0 @@ |
@@ -11,3 +11,3 @@ // Initial env variable setup for tests. | ||
import {rmRF} from '@actions/io' | ||
import {setFailed} from '@actions/core' | ||
import {setFailed, exportVariable} from '@actions/core' | ||
@@ -53,4 +53,22 @@ const originalAction = JSON.stringify(action) | ||
expect(rmRF).toBeCalledTimes(1) | ||
expect(exportVariable).toBeCalledTimes(1) | ||
}) | ||
it('should run through the commands and succeed', async () => { | ||
Object.assign(action, { | ||
repositoryPath: 'JamesIves/github-pages-deploy-action', | ||
folder: 'build', | ||
branch: 'branch', | ||
gitHubToken: '123', | ||
pusher: { | ||
name: 'asd', | ||
email: 'as@cat' | ||
} | ||
}) | ||
await run(action) | ||
expect(execute).toBeCalledTimes(17) | ||
expect(rmRF).toBeCalledTimes(1) | ||
expect(exportVariable).toBeCalledTimes(1) | ||
}) | ||
it('should throw if an error is encountered', async () => { | ||
@@ -73,3 +91,4 @@ Object.assign(action, { | ||
expect(setFailed).toBeCalledTimes(1) | ||
expect(exportVariable).toBeCalledTimes(1) | ||
}) | ||
}) |
@@ -76,3 +76,3 @@ import { | ||
} | ||
expect(generateTokenType(action)).toEqual('...') | ||
expect(generateTokenType(action)).toEqual('…') | ||
}) | ||
@@ -79,0 +79,0 @@ }) |
@@ -10,17 +10,11 @@ --- | ||
**Describe the bug** | ||
<!-- Please provide a clear and concise description of what the bug is. --> | ||
> Please provide a clear and concise description of what the bug is. | ||
**Reproduce** | ||
<!-- Steps to reproduce the behavior. --> | ||
> Steps to reproduce the behavior. | ||
**Logs** | ||
<!-- Please provide your deployment logs and a link or sample to/of your workflow. If the error message isn't revealing the problem please set ACTIONS_STEP_DEBUG to true in your repository's secrets menu and run the workflow again. --> | ||
> Please provide your deployment logs and a link to your workflow file. | ||
**Additional Comments** | ||
> Add any other context about the problem here. | ||
<!--Add any other context about the problem here. --> |
@@ -10,11 +10,8 @@ --- | ||
**Is your feature request related to a problem? Please describe.** | ||
<!-- Please provide a clear and concise description of what the problem is. Please be sure to read the README first! --> | ||
> Please provide a clear and concise description of what the problem is. | ||
**Describe the solution you'd like** | ||
<!-- Please provide a clear and concise description of what you want to happen. --> | ||
> Please provide a clear and concise description of what you want to happen. | ||
**Additional Comments** | ||
> Add any other context about the feature request here. | ||
<!-- Add any other context about the feature request here. --> |
@@ -10,12 +10,8 @@ --- | ||
**Describe the Issue** | ||
<!-- Please provide a clear and concise description of what the problem is. Please be sure to read the README first! --> | ||
> Please provide a clear and concise description of what the problem is. | ||
**Logs** | ||
<!-- Please provide your deployment logs and a link or sample to/of your workflow. If the error message isn't revealing the problem please set ACTIONS_STEP_DEBUG to true in your repository's secrets menu and run the workflow again. --> | ||
> Please provide your deployment logs and a link to your workflow file. | ||
**Additional Comments** | ||
> Add any other context about the issue here. | ||
<!-- Add any other context about the issue here. --> |
@@ -44,1 +44,8 @@ export interface ActionInterface { | ||
export declare const action: ActionInterface; | ||
/** Status codes for the action. */ | ||
export declare enum Status { | ||
SUCCESS = "success", | ||
FAILED = "failed", | ||
SKIPPED = "skipped", | ||
RUNNING = "running" | ||
} |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Status = exports.action = void 0; | ||
const core_1 = require("@actions/core"); | ||
@@ -57,1 +70,9 @@ const github = __importStar(require("@actions/github")); | ||
}; | ||
/** Status codes for the action. */ | ||
var Status; | ||
(function (Status) { | ||
Status["SUCCESS"] = "success"; | ||
Status["FAILED"] = "failed"; | ||
Status["SKIPPED"] = "skipped"; | ||
Status["RUNNING"] = "running"; | ||
})(Status = exports.Status || (exports.Status = {})); |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stdout = exports.execute = void 0; | ||
const core_1 = require("@actions/core"); | ||
@@ -14,0 +15,0 @@ const exec_1 = require("@actions/exec"); |
@@ -1,5 +0,5 @@ | ||
import { ActionInterface } from './constants'; | ||
import { ActionInterface, Status } from './constants'; | ||
export declare function init(action: ActionInterface): Promise<void | Error>; | ||
export declare function switchToBaseBranch(action: ActionInterface): Promise<void>; | ||
export declare function generateBranch(action: ActionInterface): Promise<void>; | ||
export declare function deploy(action: ActionInterface): Promise<void>; | ||
export declare function deploy(action: ActionInterface): Promise<Status>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.deploy = exports.generateBranch = exports.switchToBaseBranch = exports.init = void 0; | ||
const core_1 = require("@actions/core"); | ||
const io_1 = require("@actions/io"); | ||
const constants_1 = require("./constants"); | ||
const execute_1 = require("./execute"); | ||
@@ -126,4 +128,3 @@ const util_1 = require("./util"); | ||
if (!hasFilesToCommit && !action.isTest) { | ||
core_1.info('There is nothing to commit. Exiting early… 📭'); | ||
return; | ||
return constants_1.Status.SKIPPED; | ||
} | ||
@@ -148,2 +149,3 @@ // Commits to GitHub. | ||
yield execute_1.execute(`git checkout --progress --force ${action.defaultBranch}`, action.workspace); | ||
return constants_1.Status.SUCCESS; | ||
} | ||
@@ -150,0 +152,0 @@ catch (error) { |
@@ -12,8 +12,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateBranch = exports.deploy = exports.init = void 0; | ||
const core_1 = require("@actions/core"); | ||
const constants_1 = require("./constants"); | ||
const git_1 = require("./git"); | ||
exports.deploy = git_1.deploy; | ||
exports.generateBranch = git_1.generateBranch; | ||
exports.init = git_1.init; | ||
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return git_1.deploy; } }); | ||
Object.defineProperty(exports, "generateBranch", { enumerable: true, get: function () { return git_1.generateBranch; } }); | ||
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return git_1.init; } }); | ||
const util_1 = require("./util"); | ||
@@ -26,3 +27,3 @@ /** Initializes and runs the action. | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let errorState = false; | ||
let status = constants_1.Status.RUNNING; | ||
try { | ||
@@ -35,12 +36,16 @@ core_1.info('Checking configuration and starting deployment… 🚦'); | ||
yield git_1.init(settings); | ||
yield git_1.deploy(settings); | ||
status = yield git_1.deploy(settings); | ||
} | ||
catch (error) { | ||
errorState = true; | ||
status = constants_1.Status.FAILED; | ||
core_1.setFailed(error.message); | ||
} | ||
finally { | ||
core_1.info(`${errorState | ||
console.log(status); | ||
core_1.info(`${status === constants_1.Status.FAILED | ||
? 'Deployment Failed ❌' | ||
: 'Completed Deployment Successfully! ✅'}`); | ||
: status === constants_1.Status.SUCCESS | ||
? 'Completed Deployment Successfully! ✅' | ||
: 'There is nothing to commit. Exiting early… 📭'}`); | ||
core_1.exportVariable('DEPLOYMENT_STATUS', status); | ||
} | ||
@@ -47,0 +52,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.suppressSensitiveInformation = exports.hasRequiredParameters = exports.generateRepositoryPath = exports.generateTokenType = exports.isNullOrUndefined = void 0; | ||
const core_1 = require("@actions/core"); | ||
@@ -13,3 +14,3 @@ /* Utility function that checks to see if a value is undefined or not. */ | ||
? 'GitHub Token' | ||
: '...'; | ||
: '…'; | ||
/* Generates a the repository path used to make the commits. */ | ||
@@ -24,3 +25,4 @@ exports.generateRepositoryPath = (action) => action.ssh | ||
exports.isNullOrUndefined(action.ssh)) || | ||
exports.isNullOrUndefined(action.repositoryPath)) { | ||
exports.isNullOrUndefined(action.repositoryPath) || | ||
(action.accessToken && action.accessToken === '')) { | ||
throw new Error('No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'); | ||
@@ -27,0 +29,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)", | ||
"version": "3.4.9", | ||
"version": "3.4.10", | ||
"license": "MIT", | ||
@@ -37,20 +37,20 @@ "main": "lib/lib.js", | ||
"dependencies": { | ||
"@actions/core": "1.2.3", | ||
"@actions/core": "1.2.4", | ||
"@actions/exec": "1.0.4", | ||
"@actions/github": "2.1.1", | ||
"@actions/github": "2.2.0", | ||
"@actions/io": "1.0.2" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "25.2.1", | ||
"@types/node": "13.13.4", | ||
"eslint": "6.8.0", | ||
"@types/jest": "25.2.2", | ||
"@types/node": "14.0.1", | ||
"eslint": "7.0.0", | ||
"eslint-plugin-github": "3.4.1", | ||
"eslint-plugin-jest": "23.8.2", | ||
"eslint-plugin-jest": "23.11.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"jest": "25.5.0", | ||
"jest-circus": "25.5.1", | ||
"jest": "25.5.4", | ||
"jest-circus": "26.0.1", | ||
"prettier": "2.0.5", | ||
"ts-jest": "25.4.0", | ||
"typescript": "3.8.3" | ||
"ts-jest": "25.5.1", | ||
"typescript": "3.9.2" | ||
} | ||
} |
@@ -118,3 +118,3 @@ <p align="center"> | ||
The `with` portion of the workflow **must** be configured before the action will work. You can add these in the `with` section found in the examples above. Any `secrets` must be referenced using the bracket syntax and stored in the GitHub repositories `Settings/Secrets` menu. You can learn more about setting environment variables with GitHub actions [here](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets). | ||
The `with` portion of the workflow **must** be configured before the action will work. You can add these in the `with` section found in the examples above. Any `secrets` must be referenced using the bracket syntax and stored in the GitHub repository's `Settings/Secrets` menu. You can learn more about setting environment variables with GitHub actions [here](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets). | ||
@@ -127,5 +127,5 @@ #### Required Setup | ||
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- | | ||
| `GITHUB_TOKEN` | In order for GitHub to trigger the rebuild of your page you must provide the action with the repository's provided GitHub token. This can be referenced in the workflow `yml` file by using `${{ secrets.GITHUB_TOKEN }}`. If you experience any issues with your changes not being reflected after the deployment it may be neccersary to use either the `SSH` or `ACCESS_TOKEN` options. | `secrets / with` | **Yes** | | ||
| `SSH` | You can configure the action to deploy using SSH by setting this option to `true`. For more information on how to add your ssh key pair please refer to the [Using a Deploy Key section of this README](https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key-). | `with` | **Yes** | | ||
| `ACCESS_TOKEN` | Depending on the repository permissions you may need to provide the action with a GitHub personal access token instead of the provided GitHub token in order to deploy. You can [learn more about how to generate one here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). **This should be stored as a secret**. | `secrets / with` | **Yes** | | ||
| `GITHUB_TOKEN` | In order for GitHub to trigger the rebuild of your page you must provide the action with the repositories provided GitHub token. This can be referenced in the workflow `yml` file by using `${{ secrets.GITHUB_TOKEN }}`. **Please note there is currently an issue affecting the use of this token which makes it so it only works with private repositories, [you can learn more here](https://github.com/JamesIves/github-pages-deploy-action/issues/5)**. | `secrets / with` | **Yes** | | ||
| `ACCESS_TOKEN` | Depending on the repository's permissions you may need to provide the action with a GitHub personal access token instead of the provided GitHub token in order to deploy. You can [learn more about how to generate one here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). **This should be stored as a secret**. | `secrets / with` | **Yes** | | ||
@@ -145,3 +145,3 @@ In addition to the deployment options you must also configure the following. | ||
| `GIT_CONFIG_EMAIL` | Allows you to customize the email that is attached to the git config which is used when pushing the deployment commits. If this is not included it will use the email in the GitHub context, followed by a generic noreply GitHub email. | `with` | **No** | | ||
| `REPOSITORY_NAME` | Allows you to speicfy a different repository path so long as you have permissions to push to it. This should be formatted like so: `JamesIves/github-pages-deploy-action`. | `with` | **No** | | ||
| `REPOSITORY_NAME` | Allows you to specify a different repository path so long as you have permissions to push to it. This should be formatted like so: `JamesIves/github-pages-deploy-action`. | `with` | **No** | | ||
| `TARGET_FOLDER` | If you'd like to push the contents of the deployment folder into a specific directory on the deployment branch you can specify it here. | `with` | **No** | | ||
@@ -157,2 +157,12 @@ | `BASE_BRANCH` | The base branch of your repository which you'd like to checkout prior to deploying. This defaults to the current commit [SHA](http://en.wikipedia.org/wiki/SHA-1) that triggered the build followed by `master` if it doesn't exist. This is useful for making deployments from another branch, and also may be necessary when using a scheduled job. | `with` | **No** | | ||
#### Deployment Status | ||
The action will export an environment variable called `DEPLOYMENT_STATUS` that you can use in your workflow to determine if the deployment was successful or not. You can find an explanation of each status code below. | ||
| Status | Description | | ||
| ------------- |-------------| | ||
| `success` | The `success` status indicates that the action was able to successfully deploy the project to the branch. | | ||
| `failed` | The `failed` status indicates that the action encountered an error while trying to deploy the project. | | ||
| `skipped` | The `skipped` status indicates that the action exited early as there was nothing new to deploy. | | ||
--- | ||
@@ -168,3 +178,3 @@ | ||
Once you've generated the key pair you must add the contents of the public key within your repositories [deploy keys menu](https://developer.github.com/v3/guides/managing-deploy-keys/). You can find this option by going to `Settings > Deploy Keys`, you can name the public key whatever you want, but you **do** need to give it write access. Afterwards add the contents of the private key to the `Settings > Secrets` menu as `DEPLOY_KEY`. | ||
Once you've generated the key pair you must add the contents of the public key within your repository's [deploy keys menu](https://developer.github.com/v3/guides/managing-deploy-keys/). You can find this option by going to `Settings > Deploy Keys`, you can name the public key whatever you want, but you **do** need to give it write access. Afterwards add the contents of the private key to the `Settings > Secrets` menu as `DEPLOY_KEY`. | ||
@@ -171,0 +181,0 @@ With this configured you must add the `ssh-agent` step to your workflow and set `SSH` to `true` within the deploy action. There are several SSH actions available on the [GitHub marketplace](https://github.com/marketplace?type=actions) for you to choose from. |
@@ -96,1 +96,9 @@ import {getInput} from '@actions/core' | ||
} | ||
/** Status codes for the action. */ | ||
export enum Status { | ||
SUCCESS = 'success', | ||
FAILED = 'failed', | ||
SKIPPED = 'skipped', | ||
RUNNING = 'running' | ||
} |
import {info} from '@actions/core' | ||
import {rmRF, mkdirP} from '@actions/io' | ||
import {ActionInterface} from './constants' | ||
import {ActionInterface, Status} from './constants' | ||
import {execute} from './execute' | ||
@@ -95,3 +95,3 @@ import { | ||
/* Runs the necessary steps to make the deployment. */ | ||
export async function deploy(action: ActionInterface): Promise<void> { | ||
export async function deploy(action: ActionInterface): Promise<Status> { | ||
const temporaryDeploymentDirectory = 'gh-action-temp-deployment-folder' | ||
@@ -183,4 +183,3 @@ const temporaryDeploymentBranch = 'gh-action-temp-deployment-branch' | ||
if (!hasFilesToCommit && !action.isTest) { | ||
info('There is nothing to commit. Exiting early… 📭') | ||
return | ||
return Status.SKIPPED | ||
} | ||
@@ -241,2 +240,4 @@ | ||
) | ||
return Status.SUCCESS | ||
} catch (error) { | ||
@@ -243,0 +244,0 @@ throw new Error( |
@@ -1,3 +0,3 @@ | ||
import {info, setFailed} from '@actions/core' | ||
import {action, ActionInterface} from './constants' | ||
import {exportVariable, info, setFailed} from '@actions/core' | ||
import {action, ActionInterface, Status} from './constants' | ||
import {deploy, generateBranch, init} from './git' | ||
@@ -13,3 +13,3 @@ import {generateRepositoryPath, generateTokenType} from './util' | ||
): Promise<void> { | ||
let errorState = false | ||
let status: Status = Status.RUNNING | ||
@@ -29,14 +29,19 @@ try { | ||
await init(settings) | ||
await deploy(settings) | ||
status = await deploy(settings) | ||
} catch (error) { | ||
errorState = true | ||
status = Status.FAILED | ||
setFailed(error.message) | ||
} finally { | ||
console.log(status) | ||
info( | ||
`${ | ||
errorState | ||
status === Status.FAILED | ||
? 'Deployment Failed ❌' | ||
: 'Completed Deployment Successfully! ✅' | ||
: status === Status.SUCCESS | ||
? 'Completed Deployment Successfully! ✅' | ||
: 'There is nothing to commit. Exiting early… 📭' | ||
}` | ||
) | ||
exportVariable('DEPLOYMENT_STATUS', status) | ||
} | ||
@@ -43,0 +48,0 @@ } |
@@ -16,3 +16,3 @@ import {isDebug} from '@actions/core' | ||
? 'GitHub Token' | ||
: '...' | ||
: '…' | ||
@@ -33,3 +33,4 @@ /* Generates a the repository path used to make the commits. */ | ||
isNullOrUndefined(action.ssh)) || | ||
isNullOrUndefined(action.repositoryPath) | ||
isNullOrUndefined(action.repositoryPath) || | ||
(action.accessToken && action.accessToken === '') | ||
) { | ||
@@ -36,0 +37,0 @@ throw new Error( |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1513017
50
1747
324
+ Added@actions/core@1.2.4(transitive)
+ Added@actions/github@2.2.0(transitive)
- Removed@actions/core@1.2.3(transitive)
- Removed@actions/github@2.1.1(transitive)
Updated@actions/core@1.2.4
Updated@actions/github@2.2.0