diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9cb1cdc9f..5c9d734d5 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,2 +1,2 @@ -ARG VARIANT=12 +ARG VARIANT=14 FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:${VARIANT} \ No newline at end of file diff --git a/.devcontainer/base.Dockerfile b/.devcontainer/base.Dockerfile index 16313f77e..c1b624cea 100644 --- a/.devcontainer/base.Dockerfile +++ b/.devcontainer/base.Dockerfile @@ -1,4 +1,4 @@ -ARG VARIANT=12-buster +ARG VARIANT=14-buster FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:dev-${VARIANT} # Install tslint, typescript. eslint is installed by javascript image diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 04030ab35..7f7128d1a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,15 +1,17 @@ // https://github.com/microsoft/vscode-dev-containers/tree/master/containers/typescript-node { - "name": "Node.js & TypeScript", - "build": { - "dockerfile": "Dockerfile", - "args": { - "VARIANT": "12" - } - }, - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - "extensions": ["dbaeumer.vscode-eslint"], - "remoteUser": "node" + "name": "Node.js & TypeScript", + "build": { + "dockerfile": "Dockerfile", + "args": { + "VARIANT": "14" + } + }, + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "extensions": [ + "dbaeumer.vscode-eslint" + ], + "remoteUser": "node" } diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md index 0c6b9d84e..63d482977 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.md +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -17,7 +17,11 @@ labels: ## Logs - + + +## Workflow + + ## Additional Comments diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8b4845b80..8706feda9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,10 @@ updates: interval: daily time: '10:00' open-pull-requests-limit: 10 + + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: daily + time: '10:00' + open-pull-requests-limit: 10 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1246de9fb..19d5f13e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 - - uses: actions/setup-node@v1.4.4 + - uses: actions/setup-node@v2.5.1 with: node-version: 'v14.18.1' registry-url: 'https://registry.npmjs.org' @@ -31,7 +31,7 @@ jobs: yarn test - name: Uploade CodeCov Report - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v2.1.0 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -39,9 +39,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 - - uses: actions/setup-node@v1.4.4 + - uses: actions/setup-node@v2.5.1 with: node-version: 'v14.18.1' registry-url: 'https://registry.npmjs.org' @@ -77,11 +77,11 @@ jobs: max-parallel: 1 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: persist-credentials: false - - uses: actions/setup-node@v1.4.4 + - uses: actions/setup-node@v2.5.1 with: node-version: 'v14.18.1' registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cc4519454..622a18909 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 - name: Initialize CodeQL uses: github/codeql-action/init@v1 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 56a4ab086..c724934d1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,12 +8,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 # Workflow dispatch event that pushes the current version to the release branch. # From here the secondary production deployment workflow will trigger to build the dependencies. - name: Deploy πŸš€ - uses: JamesIves/github-pages-deploy-action@4.0.0 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: branch: releases/v4 folder: . diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 6fd6c8c1c..75e5c2516 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -20,10 +20,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: git-config-name: Montezuma git-config-email: montezuma@jamesiv.es @@ -44,7 +44,7 @@ jobs: uses: actions/checkout@v1 - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: token: ${{ secrets.ACCESS_TOKEN }} branch: gh-pages @@ -55,7 +55,7 @@ jobs: silent: true - name: Cleanup Generated Branch - uses: dawidd6/action-delete-branch@v2.0.1 + uses: dawidd6/action-delete-branch@v3.1.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} branches: gh-pages @@ -66,12 +66,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: persist-credentials: false - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: branch: gh-pages folder: integration @@ -79,7 +79,7 @@ jobs: silent: true - name: Cleanup Generated Branch - uses: dawidd6/action-delete-branch@v2.0.1 + uses: dawidd6/action-delete-branch@v3.1.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} branches: gh-pages @@ -94,7 +94,7 @@ jobs: LANG: C.UTF-8 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: persist-credentials: false @@ -103,7 +103,7 @@ jobs: apt-get update && apt-get install -y rsync - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: branch: gh-pages folder: integration @@ -111,7 +111,7 @@ jobs: silent: true - name: Cleanup Generated Branch - uses: dawidd6/action-delete-branch@v2.0.1 + uses: dawidd6/action-delete-branch@v3.1.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} branches: gh-pages @@ -122,12 +122,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: persist-credentials: false - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: ssh-key: ${{ secrets.DEPLOY_KEY }} branch: gh-pages @@ -136,7 +136,7 @@ jobs: silent: true - name: Cleanup Generated Branch - uses: dawidd6/action-delete-branch@v2.0.1 + uses: dawidd6/action-delete-branch@v3.1.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} branches: gh-pages @@ -147,17 +147,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: persist-credentials: false - name: Install SSH Client - uses: webfactory/ssh-agent@v0.4.1 + uses: webfactory/ssh-agent@v0.5.4 with: ssh-private-key: ${{ secrets.DEPLOY_KEY }} - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: ssh-key: true branch: gh-pages @@ -166,7 +166,7 @@ jobs: silent: true - name: Cleanup Generated Branch - uses: dawidd6/action-delete-branch@v2.0.1 + uses: dawidd6/action-delete-branch@v3.1.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} branches: gh-pages @@ -176,17 +176,17 @@ jobs: needs: integration-ssh-third-party-client runs-on: ubuntu-latest steps: - - uses: actions/setup-node@v1.4.4 + - uses: actions/setup-node@v2.5.1 with: node-version: 'v14.18.1' - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: persist-credentials: false - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: ssh-key: ${{ secrets.DEPLOY_KEY }} branch: gh-pages @@ -195,7 +195,7 @@ jobs: silent: true - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: ssh-key: ${{ secrets.DEPLOY_KEY }} branch: gh-pages @@ -204,7 +204,7 @@ jobs: silent: true - name: Cleanup Generated Branch - uses: dawidd6/action-delete-branch@v2.0.1 + uses: dawidd6/action-delete-branch@v3.1.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} branches: gh-pages @@ -218,17 +218,17 @@ jobs: integration-container, integration-ssh, integration-ssh-third-party-client, - integration-env + integration-env, ] runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: persist-credentials: false - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: token: ${{ secrets.ACCESS_TOKEN }} branch: gh-pages @@ -242,12 +242,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 with: persist-credentials: false - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: token: ${{ secrets.ACCESS_TOKEN }} branch: integration-test-delete-prod @@ -256,7 +256,7 @@ jobs: silent: true - name: Build and Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: token: ${{ secrets.ACCESS_TOKEN }} branch: integration-test-delete-prod @@ -266,7 +266,7 @@ jobs: silent: true - name: Cleanup Generated Branch - uses: dawidd6/action-delete-branch@v2.0.1 + uses: dawidd6/action-delete-branch@v3.1.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} branches: integration-test-delete-prod diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 846290596..e093a9d2c 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 - - uses: actions/setup-node@v1.4.4 + - uses: actions/setup-node@v2.5.1 with: node-version: 'v14.18.1' registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e926b9cac..110ab6de4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,12 +10,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2.4.0 with: ref: dev # Setup .npmrc file to publish to npm - - uses: actions/setup-node@v1.4.4 + - uses: actions/setup-node@v2.5.1 with: node-version: 'v14.18.1' registry-url: 'https://registry.npmjs.org' @@ -41,7 +41,7 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Setup .npmrc file to publish to GitHub Packages - - uses: actions/setup-node@v1.4.4 + - uses: actions/setup-node@v2.5.1 with: node-version: 'v14.18.1' registry-url: 'https://npm.pkg.github.com' diff --git a/.github/workflows/sponsors.yml b/.github/workflows/sponsors.yml index d942e8590..0f43d2678 100644 --- a/.github/workflows/sponsors.yml +++ b/.github/workflows/sponsors.yml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout πŸ›ŽοΈ - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 - name: Generate Sponsors πŸ’– - uses: JamesIves/github-sponsors-readme-action@releases/v1 + uses: JamesIves/github-sponsors-readme-action@1.0.6 with: token: ${{ secrets.PAT }} file: 'README.md' @@ -20,7 +20,7 @@ jobs: minimum: 500 - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@4.1.4 + uses: JamesIves/github-pages-deploy-action@4.1.9 with: branch: dev folder: '.' diff --git a/README.md b/README.md index 4aad6326f..8453f7b42 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout πŸ›ŽοΈ - uses: actions/checkout@v2.3.1 + uses: actions/checkout@v2.5.1 - name: Install and Build πŸ”§ # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. run: | @@ -60,7 +60,7 @@ jobs: npm run build - name: Deploy πŸš€ - uses: JamesIves/github-pages-deploy-action@4.1.9 + uses: JamesIves/github-pages-deploy-action@4.2.0 with: branch: gh-pages # The branch the action should deploy to. folder: build # The folder the action should deploy. @@ -75,7 +75,7 @@ on: - main ``` -It's recommended that you use [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/managing-vulnerabilities-in-your-projects-dependencies/configuring-dependabot-security-updates) 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). +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). #### Install as a Node Module πŸ“¦ @@ -137,7 +137,7 @@ By default the action does not need any token configuration and uses the provide | Key | Value Information | Type | Required | | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- | | `git-config-name` | Allows you to customize the name that is attached to the git config which is used when pushing the deployment commits. If this is not included it will use the name in the GitHub context, followed by the name of the action. | `with` | **No** | -| `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. You can include `<>` for the value if you wish to omit this field altogether and push the commits without an email. | `with` | **No** | +| `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. You can include `<>` for the value if you wish to omit this field altogether and push the commits without an email. | `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`. You'll need to use a PAT in the `token` input for this configuration option to work properly. | `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** | | `commit-message` | If you need to customize the commit message for an integration you can do so. | `with` | **No** | @@ -178,7 +178,7 @@ With this configured you can then set the `ssh-key` part of the action to your p ```yml - name: Deploy πŸš€ - uses: JamesIves/github-pages-deploy-action@4.1.9 + uses: JamesIves/github-pages-deploy-action@4.2.0 with: branch: gh-pages folder: site @@ -199,7 +199,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout πŸ›ŽοΈ - uses: actions/checkout@v2.3.1 + uses: actions/checkout@v2.5.1 - name: Install and Build πŸ”§ # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. run: | @@ -207,7 +207,7 @@ jobs: npm run build - name: Deploy πŸš€ - uses: JamesIves/github-pages-deploy-action@4.1.9 + uses: JamesIves/github-pages-deploy-action@4.2.0 with: branch: gh-pages folder: build @@ -248,7 +248,7 @@ jobs: runs-on: windows-latest # The first job utilizes windows-latest steps: - name: Checkout πŸ›ŽοΈ - uses: actions/checkout@v2.3.1 + uses: actions/checkout@v2.5.1 - name: Install and Build πŸ”§ # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. run: | @@ -266,7 +266,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout πŸ›ŽοΈ - uses: actions/checkout@v2.3.1 + uses: actions/checkout@v2.5.1 - name: Download Artifacts πŸ”» # The built project is downloaded into the 'site' folder. uses: actions/download-artifact@v1 @@ -274,7 +274,7 @@ jobs: name: site - name: Deploy πŸš€ - uses: JamesIves/github-pages-deploy-action@4.1.9 + uses: JamesIves/github-pages-deploy-action@4.2.0 with: branch: gh-pages folder: 'site' # The deployment folder should match the name of the artifact. Even though our project builds into the 'build' folder the artifact name of 'site' must be placed here. @@ -295,7 +295,7 @@ If you use a [container](https://help.github.com/en/actions/automating-your-work apt-get update && apt-get install -y rsync - name: Deploy πŸš€ - uses: JamesIves/github-pages-deploy-action@4.1.9 + uses: JamesIves/github-pages-deploy-action@4.2.0 ``` --- @@ -318,7 +318,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout πŸ›ŽοΈ - uses: actions/checkout@v2.3.1 + uses: actions/checkout@v2.5.1 - name: Install and Build πŸ”§ # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. run: | @@ -326,7 +326,7 @@ jobs: npm run build - name: Deploy πŸš€ - uses: JamesIves/github-pages-deploy-action@4.1.9 + uses: JamesIves/github-pages-deploy-action@4.2.0 with: branch: gh-pages folder: build diff --git a/SECURITY.md b/SECURITY.md index 0ff879b04..917da7150 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -7,7 +7,7 @@ The current version is actively maintained and will receive frequent updates and | Version | Supported | | ------- | ------------------ | | 4.0.x | :white_check_mark: | -| < 4.0.0 | :x: | +| < 4.0.0 | :x: | ## Reporting a Vulnerability diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index 469556cbf..366da22b4 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -55,7 +55,7 @@ describe('git', () => { }) await init(action) - expect(execute).toBeCalledTimes(5) + expect(execute).toBeCalledTimes(6) }) it('should catch when a function throws an error', async () => { @@ -102,7 +102,7 @@ describe('git', () => { }) await init(action) - expect(execute).toBeCalledTimes(5) + expect(execute).toBeCalledTimes(6) }) it('should not unset git config if a user is using ssh', async () => { @@ -124,7 +124,7 @@ describe('git', () => { }) await init(action) - expect(execute).toBeCalledTimes(4) + expect(execute).toBeCalledTimes(5) process.env.CI = undefined }) @@ -145,7 +145,7 @@ describe('git', () => { }) await init(action) - expect(execute).toBeCalledTimes(5) + expect(execute).toBeCalledTimes(6) }) }) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 510e7c65e..7cf28f8fa 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -2,6 +2,7 @@ process.env['INPUT_FOLDER'] = 'build' process.env['GITHUB_SHA'] = '123' process.env['INPUT_DEBUG'] = 'debug' +process.env['GITHUB_REF_NAME'] = 'test' import '../src/main' import {action, TestFlag} from '../src/constants' @@ -49,7 +50,7 @@ describe('main', () => { debug: true }) await run(action) - expect(execute).toBeCalledTimes(15) + expect(execute).toBeCalledTimes(16) expect(rmRF).toBeCalledTimes(1) expect(exportVariable).toBeCalledTimes(1) }) @@ -69,7 +70,7 @@ describe('main', () => { isTest: TestFlag.HAS_CHANGED_FILES }) await run(action) - expect(execute).toBeCalledTimes(18) + expect(execute).toBeCalledTimes(19) expect(rmRF).toBeCalledTimes(1) expect(exportVariable).toBeCalledTimes(1) }) diff --git a/package.json b/package.json index d44135256..f6ed25182 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.1.8", + "version": "4.1.9", "license": "MIT", "main": "lib/lib.js", "types": "lib/lib.d.ts", diff --git a/src/constants.ts b/src/constants.ts index a2f682af6..02e9e8bbe 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -148,3 +148,21 @@ export enum Status { SKIPPED = 'skipped', RUNNING = 'running' } + +/* Platform codes. */ +export enum OperatingSystems { + LINUX = 'Linux', + WINDOWS = 'Windows', + MACOS = 'macOS' +} + +export const SupportedOperatingSystems = [OperatingSystems.LINUX] + +/* Excluded files. */ +export enum DefaultExcludedFiles { + CNAME = 'CNAME', + NOJEKYLL = '.nojekyll', + SSH = '.ssh', + GIT = '.git', + GITHUB = '.github' +} diff --git a/src/git.ts b/src/git.ts index 291511b20..45ab9821f 100644 --- a/src/git.ts +++ b/src/git.ts @@ -1,7 +1,12 @@ import {info} from '@actions/core' import {mkdirP, rmRF} from '@actions/io' import fs from 'fs' -import {ActionInterface, Status, TestFlag} from './constants' +import { + ActionInterface, + DefaultExcludedFiles, + Status, + TestFlag +} from './constants' import {execute} from './execute' import {generateWorktree} from './worktree' import { @@ -21,12 +26,19 @@ export async function init(action: ActionInterface): Promise { action.workspace, action.silent ) + await execute( `git config user.email "${action.email}"`, action.workspace, action.silent ) + await execute( + `git config core.ignorecase false`, + action.workspace, + action.silent + ) + try { if ((process.env.CI && !action.sshKey) || action.isTest) { /* Ensures that previously set Git configs do not interfere with the deployment. @@ -129,16 +141,22 @@ export async function deploy(action: ActionInterface): Promise { } ${ action.clean ? `--delete ${excludes} ${ - !fs.existsSync(`${action.folderPath}/CNAME`) - ? '--exclude CNAME' + !fs.existsSync( + `${action.folderPath}/${DefaultExcludedFiles.CNAME}` + ) + ? `--exclude ${DefaultExcludedFiles.CNAME}` : '' } ${ - !fs.existsSync(`${action.folderPath}/.nojekyll`) - ? '--exclude .nojekyll' + !fs.existsSync( + `${action.folderPath}/${DefaultExcludedFiles.NOJEKYLL}` + ) + ? `--exclude ${DefaultExcludedFiles.NOJEKYLL}` : '' }` : '' - } --exclude .ssh --exclude .git --exclude .github ${ + } --exclude ${DefaultExcludedFiles.SSH} --exclude ${ + DefaultExcludedFiles.GIT + } --exclude ${DefaultExcludedFiles.GITHUB} ${ action.folderPath === action.workspace ? `--exclude ${temporaryDeploymentDirectory}` : '' diff --git a/src/lib.ts b/src/lib.ts index 5703e7c0c..6af2976de 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -23,12 +23,12 @@ export default async function run( info(` GitHub Pages Deploy Action πŸš€ - πŸš€ Getting Started Guide: https://github.com/marketplace/actions/deploy-to-github-pages - ❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions - πŸ”§ Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues - + πŸ’– Support: https://github.com/sponsors/JamesIves πŸ“£ Maintained by James Ives: https://jamesiv.es - πŸ’– Support: https://github.com/sponsors/JamesIves`) + + πŸš€ Getting Started Guide: https://github.com/JamesIves/github-pages-deploy-action + ❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions + πŸ”§ Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues`) info('Checking configuration and starting deployment… 🚦') diff --git a/src/util.ts b/src/util.ts index 927fea613..ae44704da 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,7 +1,12 @@ -import {isDebug} from '@actions/core' +import {isDebug, info} from '@actions/core' import {existsSync} from 'fs' import path from 'path' -import {ActionInterface, RequiredActionParameters} from './constants' +import { + ActionInterface, + OperatingSystems, + RequiredActionParameters, + SupportedOperatingSystems +} from './constants' /* Replaces all instances of a match in a string. */ const replaceAll = (input: string, find: string, replace: string): string => @@ -66,6 +71,16 @@ export const checkParameters = (action: ActionInterface): void => { `The directory you're trying to deploy named ${action.folderPath} doesn't exist. Please double check the path and any prerequisite build scripts and try again. ❗` ) } + + if ( + SupportedOperatingSystems.includes( + process.env.RUNNER_OS as OperatingSystems + ) + ) { + info( + `The operating system you're using is not supported and results may be varied. Please refer to the documentation for more details. ❗` + ) + } } /* Suppresses sensitive information from being exposed in error messages. */ diff --git a/src/worktree.ts b/src/worktree.ts index 9ef472221..d45174283 100644 --- a/src/worktree.ts +++ b/src/worktree.ts @@ -43,28 +43,39 @@ export async function generateWorktree( action.workspace, action.silent ) + const checkout = new GitCheckout(action.branch) + if (branchExists) { // There's existing data on the branch to check out checkout.commitish = `origin/${action.branch}` } - if (!branchExists || action.singleCommit) { - // Create a new history if we don't have the branch, or if we want to reset it + + if ( + !branchExists || + (action.singleCommit && action.branch !== process.env.GITHUB_REF_NAME) + ) { + /* Create a new history if we don't have the branch, or if we want to reset it. + If the ref name is the same as the branch name, do not attempt to create an orphan of it. */ checkout.orphan = true } + await execute( checkout.toString(), `${action.workspace}/${worktreedir}`, action.silent ) + if (!branchExists) { info(`Created the ${action.branch} branch… πŸ”§`) + // Our index is in HEAD state, reset await execute( 'git reset --hard', `${action.workspace}/${worktreedir}`, action.silent ) + if (!action.singleCommit) { // New history isn't singleCommit, create empty initial commit await execute(