docs: Updated docs to remove workspace

This commit is contained in:
James Ives 2022-08-17 08:35:29 -04:00
parent b7b8bb2c63
commit 09a5452132
7 changed files with 46 additions and 21 deletions

View File

@ -132,7 +132,6 @@ By default, the action does not need any token configuration and uses the provid
| `single-commit` | This option can be toggled to `true` if you'd prefer to have a single commit on the deployment branch instead of maintaining the full history. **Using this option will also cause any existing history to be wiped from the deployment branch**. | `with` | **No** |
| `force` | Force-push new deployments to overwrite the previous version; otherwise, attempt to rebase new deployments onto any existing ones. This option is turned on by default and can be toggled off by setting it to `false`, which may be useful if there are multiple deployments in a single branch. | `with` | **No** |
| `silent` | Silences the action output preventing it from displaying git messages. | `with` | **No** |
| `workspace` | This should point to where your project lives on the virtual machine. The GitHub Actions environment will set this for you. It is only necessary to set this variable if you're using the node module. | `with` | **No** |
| `tag` | Add a tag to the commit. Only works when `dry-run` is not used. | `with` | **No** |
With the action correctly configured you should see the workflow trigger the deployment under the configured conditions.

View File

@ -24,7 +24,7 @@ inputs:
However if you need more permissions for things such as deploying to another repository, you can add a Personal Access Token (PAT) here.
This should be stored in the `secrets / with` menu **as a secret**.
We recommend using a service account with the least permissions neccersary
We recommend using a service account with the least permissions necessary
and when generating a new PAT that you select the least permission scopes required.
[Learn more about creating and using encrypted secrets here.](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
@ -58,7 +58,7 @@ inputs:
required: false
dry-run:
description: 'Do not actually push back, but use `--dry-run` on `git push` invocations insead.'
description: 'Do not actually push back, but use `--dry-run` on `git push` invocations instead.'
required: false
force:
@ -78,10 +78,6 @@ inputs:
description: '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'
required: false
workspace:
description: "This should point to where your project lives on the virtual machine. The GitHub Actions environment will set this for you. It is only neccersary to set this variable if you're using the node module."
required: false
tag:
description: "Add a tag to the commit, this can be used like so: 'v0.1'. Only works when 'dry-run' is not used."
required: false

View File

@ -42,7 +42,7 @@ export interface ActionInterface {
name?: string
/** The repository path, for example JamesIves/github-pages-deploy-action. */
repositoryName?: string
/** The fully qualified repositpory path, this gets auto generated if repositoryName is provided. */
/** The fully qualified repository path, this gets auto generated if repositoryName is provided. */
repositoryPath?: string
/** Wipes the commit history from the deployment branch in favor of a single commit. */
singleCommit?: boolean | null

View File

@ -15,7 +15,9 @@ import {
suppressSensitiveInformation
} from './util'
/* Initializes git in the workspace. */
/**
* Initializes git in the workspace.
*/
export async function init(action: ActionInterface): Promise<void | Error> {
try {
info(`Deploying using ${action.tokenType}… 🔑`)
@ -96,7 +98,9 @@ export async function init(action: ActionInterface): Promise<void | Error> {
}
}
/* Runs the necessary steps to make the deployment. */
/**
* Runs the necessary steps to make the deployment.
*/
export async function deploy(action: ActionInterface): Promise<Status> {
const temporaryDeploymentDirectory =
'github-pages-deploy-action-temp-deployment-folder'

View File

@ -5,6 +5,9 @@ import {appendFileSync} from 'fs'
import {ActionInterface} from './constants'
import {extractErrorMessage, suppressSensitiveInformation} from './util'
/**
* Configures SSH for the workflow.
*/
export async function configureSSH(action: ActionInterface): Promise<void> {
try {
if (typeof action.sshKey === 'string') {

View File

@ -8,22 +8,30 @@ import {
SupportedOperatingSystems
} from './constants'
/* Replaces all instances of a match in a string. */
/**
* Replaces all instances of a match in a string.
*/
const replaceAll = (input: string, find: string, replace: string): string =>
input.split(find).join(replace)
/* Utility function that checks to see if a value is undefined or not.
If allowEmptyString is passed the parameter is allowed to contain an empty string as a valid parameter. */
/**
* Utility function that checks to see if a value is undefined or not.
* If allowEmptyString is passed the parameter is allowed to contain an empty string as a valid parameter.
*/
export const isNullOrUndefined = (
value: unknown
): value is undefined | null | '' =>
typeof value === 'undefined' || value === null || value === ''
/* Generates a token type used for the action. */
/**
* Generates a token type used for the action.
*/
export const generateTokenType = (action: ActionInterface): string =>
action.sshKey ? 'SSH Deploy Key' : action.token ? 'Deploy Token' : '…'
/* Generates a the repository path used to make the commits. */
/**
* Generates a the repository path used to make the commits.
*/
export const generateRepositoryPath = (action: ActionInterface): string =>
action.sshKey
? `git@${action.hostname}:${action.repositoryName}`
@ -31,7 +39,9 @@ export const generateRepositoryPath = (action: ActionInterface): string =>
action.repositoryName
}.git`
/* Genetate absolute folder path by the provided folder name */
/**
* Generate absolute folder path by the provided folder name
*/
export const generateFolderPath = (action: ActionInterface): string => {
const folderName = action['folder']
return path.isAbsolute(folderName)
@ -41,7 +51,9 @@ export const generateFolderPath = (action: ActionInterface): string => {
: path.join(action.workspace, folderName)
}
/* Checks for the required tokens and formatting. Throws an error if any case is matched. */
/**
* Checks for the required tokens and formatting. Throws an error if any case is matched.
*/
const hasRequiredParameters = <K extends keyof RequiredActionParameters>(
action: ActionInterface,
params: K[]
@ -53,7 +65,9 @@ const hasRequiredParameters = <K extends keyof RequiredActionParameters>(
return Boolean(nonNullParams.length)
}
/* Verifies the action has the required parameters to run, otherwise throw an error. */
/**
* Verifies the action has the required parameters to run, otherwise throw an error.
*/
export const checkParameters = (action: ActionInterface): void => {
if (!hasRequiredParameters(action, ['token', 'sshKey'])) {
throw new Error(
@ -86,7 +100,9 @@ export const checkParameters = (action: ActionInterface): void => {
}
}
/* Suppresses sensitive information from being exposed in error messages. */
/**
* Suppresses sensitive information from being exposed in error messages.
*/
export const suppressSensitiveInformation = (
str: string,
action: ActionInterface
@ -109,6 +125,9 @@ export const suppressSensitiveInformation = (
return value
}
/**
* Extracts message from an error object.
*/
export const extractErrorMessage = (error: unknown): string =>
error instanceof Error
? error.message
@ -116,6 +135,8 @@ export const extractErrorMessage = (error: unknown): string =>
? error
: JSON.stringify(error)
/** Strips the protocol from a provided URL. */
/**
* Strips the protocol from a provided URL.
*/
export const stripProtocolFromUrl = (url: string): string =>
url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').split('/')[0]

View File

@ -21,7 +21,9 @@ export class GitCheckout {
}
}
/* Generate the worktree and set initial content if it exists */
/**
* Generate the worktree and set initial content if it exists
*/
export async function generateWorktree(
action: ActionInterface,
worktreedir: string,