diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 51137cf7b..a74626950 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: yarn test - name: Uploade CodeCov Report - uses: codecov/codecov-action@v3.1.0 + uses: codecov/codecov-action@v3.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 59a44dd0f..29fc1479a 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -34,6 +34,7 @@ jobs: git-config-email: montezuma@jamesiv.es repository-name: MontezumaIves/lab token: ${{ secrets.ACCESS_TOKEN }} + commit-message: 'Test commit' folder: integration single-commit: true clean: true diff --git a/.github/workflows/sponsors.yml b/.github/workflows/sponsors.yml index ae6f95663..98ac62d6c 100644 --- a/.github/workflows/sponsors.yml +++ b/.github/workflows/sponsors.yml @@ -18,7 +18,6 @@ jobs: file: 'README.md' template: '{{{ login }}}  ' maximum: 9999 - organization: true - name: Generate Sponsors 💖 uses: JamesIves/github-sponsors-readme-action@v1 @@ -28,7 +27,6 @@ jobs: minimum: 10000 template: '{{{ login }}}  ' marker: 'premium' - organization: true - name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 diff --git a/README.md b/README.md index 129fed9bb..6cd05fb6c 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@

-github   +

@@ -89,52 +89,14 @@ on: - main ``` -It's recommended that you use [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically) to keep your workflow up-to-date and [secure](https://github.com/features/security). You can find the latest tagged version on the [GitHub Marketplace](https://github.com/marketplace/actions/deploy-to-github-pages) or on the [releases page](https://github.com/JamesIves/github-pages-deploy-action/releases). - -#### Permission Settings ⚠️ - -If you do not supply the action with an access token or an SSH key, you must access your repositories settings and provide `Read and Write Permissions` to the provided `GITHUB_TOKEN`, otherwise you'll potentailly run into permission issues. Alternatively you can set the following in your workflow file to grant the action the permissions it needs. +> **Warning** +> If you do not supply the action with an access token or an SSH key, you must access your repositories settings and provide `Read and Write Permissions` to the provided `GITHUB_TOKEN`, otherwise you'll potentially run into permission issues. Alternatively you can set the following in your workflow file to grant the action the permissions it needs. ```yml permissions: contents: write ``` -#### Install as a Node Module 📦 - -If you'd like to use the functionality provided by this action in your own action you can either [create a composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action), or you can install it using [yarn](https://yarnpkg.com/) or [npm](https://www.npmjs.com/get-npm) by running the following commands. It's available on both the [npm](https://www.npmjs.com/package/@jamesives/github-pages-deploy-action) and [GitHub registry](https://github.com/JamesIves/github-pages-deploy-action/packages/229985). - -``` -yarn add @jamesives/github-pages-deploy-action -``` - -``` -npm install @jamesives/github-pages-deploy-action -``` - -It can then be imported into your project like so. - -```javascript -import run from '@jamesives/github-pages-deploy-action' -``` - -Calling the functions directly will require you to pass in an object containing the variables found in the configuration section, you'll also need to provide a `workspace` with a path to your project. - -```javascript -import run from '@jamesives/github-pages-deploy-action' - -run({ - token: process.env['ACCESS_TOKEN'], - folder: 'build', - repositoryName: 'JamesIves/github-pages-deploy-action', - silent: true, - workspace: 'src/project/location', - tag: 'v0.1' -}) -``` - -For more information regarding the [action interface please click here](https://github.com/JamesIves/github-pages-deploy-action/blob/dev/src/constants.ts#L7). - ## Configuration 📁 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). @@ -170,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. diff --git a/action.yml b/action.yml index 5b1cc0546..5cb3af676 100644 --- a/action.yml +++ b/action.yml @@ -2,7 +2,7 @@ name: 'Deploy to GitHub Pages' description: 'This action will handle the deployment process of your project to GitHub Pages.' author: 'James Ives ' runs: - using: 'node12' + using: 'node16' main: 'lib/main.js' branding: icon: 'git-commit' @@ -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 diff --git a/package.json b/package.json index 11e42a0a0..77cc3a4c7 100644 --- a/package.json +++ b/package.json @@ -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 (https://jamesiv.es)", - "version": "4.3.4", + "version": "4.4.0", "license": "MIT", "main": "lib/lib.js", "types": "lib/lib.d.ts", @@ -35,25 +35,25 @@ "deployment" ], "dependencies": { - "@actions/core": "1.9.0", + "@actions/core": "1.10.0", "@actions/exec": "1.1.1", - "@actions/github": "5.0.3", + "@actions/github": "5.1.1", "@actions/io": "1.1.2" }, "devDependencies": { "@types/jest": "27.5.0", - "@types/node": "18.0.6", + "@types/node": "18.8.0", "@typescript-eslint/eslint-plugin": "4.33.0", "@typescript-eslint/parser": "4.33.0", "eslint": "7.32.0", "eslint-config-prettier": "8.5.0", - "eslint-plugin-jest": "26.5.3", + "eslint-plugin-jest": "27.0.4", "eslint-plugin-prettier": "4.2.1", "jest": "26.6.3", "jest-circus": "27.5.1", "prettier": "2.7.1", "rimraf": "3.0.2", "ts-jest": "26.5.6", - "typescript": "4.7.4" + "typescript": "4.8.4" } } diff --git a/src/constants.ts b/src/constants.ts index 85c83122c..51bbb5e41 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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 diff --git a/src/git.ts b/src/git.ts index 52ba6ed8f..581e1a86a 100644 --- a/src/git.ts +++ b/src/git.ts @@ -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 { try { info(`Deploying using ${action.tokenType}… 🔑`) @@ -96,7 +98,9 @@ export async function init(action: ActionInterface): Promise { } } -/* Runs the necessary steps to make the deployment. */ +/** + * Runs the necessary steps to make the deployment. + */ export async function deploy(action: ActionInterface): Promise { const temporaryDeploymentDirectory = 'github-pages-deploy-action-temp-deployment-folder' diff --git a/src/ssh.ts b/src/ssh.ts index 1c9039201..fb56754f0 100644 --- a/src/ssh.ts +++ b/src/ssh.ts @@ -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 { try { if (typeof action.sshKey === 'string') { diff --git a/src/util.ts b/src/util.ts index 54c13f42d..a5a6a7ff8 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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 = ( action: ActionInterface, params: K[] @@ -53,7 +65,9 @@ const hasRequiredParameters = ( 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] diff --git a/src/worktree.ts b/src/worktree.ts index d45174283..4230d3d20 100644 --- a/src/worktree.ts +++ b/src/worktree.ts @@ -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, diff --git a/yarn.lock b/yarn.lock index 77e8c9802..580f2633f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,12 +2,13 @@ # yarn lockfile v1 -"@actions/core@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.9.0.tgz#20c1baac5d4bd2508ba1fc3e5f3fc4b8a80d4082" - integrity sha512-5pbM693Ih59ZdUhgk+fts+bUWTnIdHV3kwOSr+QIoFHMLg7Gzhwm0cifDY/AG68ekEJAkHnQVpcy4f6GjmzBCA== +"@actions/core@1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f" + integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug== dependencies: "@actions/http-client" "^2.0.1" + uuid "^8.3.2" "@actions/exec@1.1.1": version "1.1.1" @@ -16,10 +17,10 @@ dependencies: "@actions/io" "^1.0.1" -"@actions/github@5.0.3": - version "5.0.3" - resolved "https://registry.yarnpkg.com/@actions/github/-/github-5.0.3.tgz#b305765d6173962d113451ea324ff675aa674f35" - integrity sha512-myjA/pdLQfhUGLtRZC/J4L1RXOG4o6aYdiEq+zr5wVVKljzbFld+xv10k1FX6IkIJtNxbAq44BdwSNpQ015P0A== +"@actions/github@5.1.1": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@actions/github/-/github-5.1.1.tgz#40b9b9e1323a5efcf4ff7dadd33d8ea51651bbcb" + integrity sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g== dependencies: "@actions/http-client" "^2.0.1" "@octokit/core" "^3.6.0" @@ -1276,10 +1277,10 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== -"@types/node@*", "@types/node@18.0.6", "@types/node@>= 8": - version "18.0.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.6.tgz#0ba49ac517ad69abe7a1508bc9b3a5483df9d5d7" - integrity sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw== +"@types/node@*", "@types/node@18.8.0", "@types/node@>= 8": + version "18.8.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.8.0.tgz#b8ee8d83a99470c0661bd899417fcd77060682fe" + integrity sha512-u+h43R6U8xXDt2vzUaVP3VwjjLyOJk6uEciZS8OSyziUQGOwmk+l+4drxcsDboHXwyTaqS1INebghmWMRxq3LA== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -2145,10 +2146,10 @@ eslint-config-prettier@8.5.0: resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1" integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q== -eslint-plugin-jest@26.5.3: - version "26.5.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.5.3.tgz#a3ceeaf4a757878342b8b00eca92379b246e5505" - integrity sha512-sICclUqJQnR1bFRZGLN2jnSVsYOsmPYYnroGCIMVSvTS3y8XR3yjzy1EcTQmk6typ5pRgyIWzbjqxK6cZHEZuQ== +eslint-plugin-jest@27.0.4: + version "27.0.4" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.0.4.tgz#ab9c7b3f48bfade4762c24c415a5d9bbc0174a61" + integrity sha512-BuvY78pHMpMJ6Cio7sKg6jrqEcnRYPUc4Nlihku4vKx3FjlmMINSX4vcYokZIe+8TKcyr1aI5Kq7vYwgJNdQSA== dependencies: "@typescript-eslint/utils" "^5.10.0" @@ -4745,10 +4746,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@4.7.4: - version "4.7.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" - integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== +typescript@4.8.4: + version "4.8.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" + integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== union-value@^1.0.0: version "1.0.1" @@ -4802,7 +4803,7 @@ use@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" -uuid@^8.3.0: +uuid@^8.3.0, uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"