Merge branch 'dev' into releases/v4

This commit is contained in:
James Ives 2021-03-04 09:03:36 -05:00
commit 45f4c85b30
20 changed files with 364 additions and 934 deletions

View File

@ -6,7 +6,6 @@ on:
- 'dev-v*' - 'dev-v*'
- 'releases/v*' - 'releases/v*'
pull_request: pull_request:
# The branches below must be a subset of the branches above
branches: branches:
- dev - dev
- 'dev-v*' - 'dev-v*'
@ -22,28 +21,11 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v1 uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v1

21
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Deploy Code to Release Branch
on:
workflow_dispatch:
jobs:
build:
name: Push to Release Branch
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# 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
with:
branch: releases/v4
folder: .
clean: false
single-commit: true

View File

@ -1,12 +1,17 @@
name: integration-tests name: integration-tests
on: on:
workflow_dispatch:
inputs:
branch:
description: 'Specifies the branch which the integration tests should run on.'
required: true
default: 'releases/v4'
schedule: schedule:
- cron: 30 15 * * 0-6 - cron: 30 15 * * 0-6
push: push:
tags-ignore: tags-ignore:
- '*.*' - '*.*'
branches: branches:
- dev
- releases/v4 - releases/v4
jobs: jobs:
@ -22,12 +27,13 @@ jobs:
with: with:
git-config-name: Montezuma git-config-name: Montezuma
git-config-email: montezuma@jamesiv.es git-config-email: montezuma@jamesiv.es
repository-name: JamesIves/lab repository-name: MontezumaIves/lab
token: ${{ secrets.ACCESS_TOKEN }} token: ${{ secrets.ACCESS_TOKEN }}
branch: gh-pages branch: gh-pages
folder: integration folder: integration
single-commit: true single-commit: true
clean: true clean: true
silent: true
# Deploys using checkout@v1 with an ACCESS_TOKEN. # Deploys using checkout@v1 with an ACCESS_TOKEN.
integration-checkout-v1: integration-checkout-v1:
@ -46,6 +52,7 @@ jobs:
target-folder: cat/montezuma target-folder: cat/montezuma
git-config-name: Montezuma git-config-name: Montezuma
git-config-email: montezuma@jamesiv.es git-config-email: montezuma@jamesiv.es
silent: true
- name: Cleanup Generated Branch - name: Cleanup Generated Branch
uses: dawidd6/action-delete-branch@v2.0.1 uses: dawidd6/action-delete-branch@v2.0.1
@ -69,6 +76,7 @@ jobs:
branch: gh-pages branch: gh-pages
folder: integration folder: integration
target-folder: cat/montezuma2 target-folder: cat/montezuma2
silent: true
- name: Cleanup Generated Branch - name: Cleanup Generated Branch
uses: dawidd6/action-delete-branch@v2.0.1 uses: dawidd6/action-delete-branch@v2.0.1
@ -101,6 +109,7 @@ jobs:
branch: gh-pages branch: gh-pages
folder: integration folder: integration
target-folder: cat/montezuma2 target-folder: cat/montezuma2
silent: true
- name: Cleanup Generated Branch - name: Cleanup Generated Branch
uses: dawidd6/action-delete-branch@v2.0.1 uses: dawidd6/action-delete-branch@v2.0.1
@ -125,6 +134,7 @@ jobs:
branch: gh-pages branch: gh-pages
folder: integration folder: integration
target-folder: cat/montezuma3 target-folder: cat/montezuma3
silent: true
- name: Cleanup Generated Branch - name: Cleanup Generated Branch
uses: dawidd6/action-delete-branch@v2.0.1 uses: dawidd6/action-delete-branch@v2.0.1
@ -150,10 +160,11 @@ jobs:
- name: Build and Deploy - name: Build and Deploy
uses: JamesIves/github-pages-deploy-action@releases/v4 uses: JamesIves/github-pages-deploy-action@releases/v4
with: with:
ssh: true ssh-key: true
branch: gh-pages branch: gh-pages
folder: integration folder: integration
target-folder: cat/montezuma4 target-folder: cat/montezuma4
silent: true
- name: Cleanup Generated Branch - name: Cleanup Generated Branch
uses: dawidd6/action-delete-branch@v2.0.1 uses: dawidd6/action-delete-branch@v2.0.1
@ -182,6 +193,7 @@ jobs:
branch: gh-pages branch: gh-pages
folder: integration folder: integration
target-folder: cat/montezuma4 target-folder: cat/montezuma4
silent: true
- name: Cleanup Generated Branch - name: Cleanup Generated Branch
uses: dawidd6/action-delete-branch@v2.0.1 uses: dawidd6/action-delete-branch@v2.0.1
@ -206,6 +218,7 @@ jobs:
branch: gh-pages branch: gh-pages
folder: integration folder: integration
clean: true clean: true
silent: true
# Deploys to a branch that doesn't exist with SINGLE_COMMIT. # Deploys to a branch that doesn't exist with SINGLE_COMMIT.
integration-branch-creation: integration-branch-creation:
@ -224,6 +237,7 @@ jobs:
branch: integration-test-delete-prod branch: integration-test-delete-prod
folder: integration folder: integration
single-commit: true single-commit: true
silent: true
- name: Cleanup Generated Branch - name: Cleanup Generated Branch
uses: dawidd6/action-delete-branch@v2.0.1 uses: dawidd6/action-delete-branch@v2.0.1

View File

@ -9,7 +9,7 @@ on:
jobs: jobs:
build: build:
name: Build production name: Build Production
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout

View File

@ -1,7 +1,10 @@
name: publish-to-npm name: publish-to-npm
on: on:
release: workflow_dispatch:
types: [created] inputs:
version:
description: 'The updated registry version number.'
required: true
jobs: jobs:
build: build:
@ -18,7 +21,7 @@ jobs:
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
scope: '@jamesives' scope: '@jamesives'
- name: Configure git - name: Configure Git
run: | run: |
git config user.email "iam@jamesiv.es" git config user.email "iam@jamesiv.es"
git config user.name "James Ives" git config user.name "James Ives"
@ -28,7 +31,7 @@ jobs:
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
- run: yarn build - run: yarn build
# - run: npm version patch -m "Release %s 📣" - run: npm version ${{ github.event.inputs.version }} -m "Release ${{ github.event.inputs.version }} 📣"
- run: git push - run: git push
# Publish to npm # Publish to npm

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020 James Ives Copyright (c) 2021 James Ives
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.

View File

@ -31,7 +31,7 @@
</p> </p>
<p align="center"> <p align="center">
This <a href="https://github.com/features/actions">GitHub Action</a> will automatically deploy your project to <a href="https://pages.github.com/">GitHub Pages</a>. It can be configured to push your production-ready code into any branch you'd like, including <b>gh-pages</b> and <b>docs</b>. It can also handle cross repository deployments too. This <a href="https://github.com/features/actions">GitHub Action</a> will automatically deploy your project to <a href="https://pages.github.com/">GitHub Pages</a>. It can be configured to push your production-ready code into any branch you'd like, including <b>gh-pages</b> and <b>docs</b>. It can also handle cross repository deployments and works with <a href="https://github.com/enterprise">GitHub Enterprise</a> too.
</p> </p>
<p align="center"> <p align="center">
@ -129,7 +129,7 @@ By default the action does not need any token configuration and uses the provide
| Key | Value Information | Type | Required | | Key | Value Information | Type | Required |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- |
| `token` | This option defaults to the repository scoped GitHub Token. 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 reccomend using a service account with the least permissions neccersary and recommend when generating a new PAT that you select the least permission scopes neccersary. [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) | `with` | **No** | | `token` | This option defaults to the repository scoped GitHub Token. 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 necessary and recommend when generating a new PAT that you select the least permission scopes necessary. [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) | `with` | **No** |
| `ssh-key` | You can configure the action to deploy using SSH by setting this option to a private SSH key stored **as a secret**. It can also be set to `true` to use an existing SSH client configuration. For more detailed information on how to add your public/private 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` | **No** | | `ssh-key` | You can configure the action to deploy using SSH by setting this option to a private SSH key stored **as a secret**. It can also be set to `true` to use an existing SSH client configuration. For more detailed information on how to add your public/private 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` | **No** |
#### Optional Choices #### Optional Choices
@ -143,7 +143,7 @@ By default the action does not need any token configuration and uses the provide
| `commit-message` | If you need to customize the commit message for an integration you can do so. | `with` | **No** | | `commit-message` | If you need to customize the commit message for an integration you can do so. | `with` | **No** |
| `clean` | If your project generates hashed files on build you can use this option to automatically delete them from the target folder on the deployment branch with each deploy. This option is turned on by default, and can be toggled off by setting it to `false`. | `with` | **No** | | `clean` | If your project generates hashed files on build you can use this option to automatically delete them from the target folder on the deployment branch with each deploy. This option is turned on by default, and can be toggled off by setting it to `false`. | `with` | **No** |
| `clean-exclude` | If you need to use `clean` but you'd like to preserve certain files or folders you can use this option. This should contain each pattern as a single line in a multiline string. | `with` | **No** | | `clean-exclude` | If you need to use `clean` but you'd like to preserve certain files or folders you can use this option. This should contain each pattern as a single line in a multiline string. | `with` | **No** |
| `dry-run` | Do not actually push back, but use `--dry-run` on `git push` invocations insead. | `with` | **No** | | `dry-run` | Do not actually push back, but use `--dry-run` on `git push` invocations instead. | `with` | **No** |
| `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** | | `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** |
| `silent` | Silences the action output preventing it from displaying git messages. | `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** | | `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** |
@ -305,8 +305,7 @@ If you use a [container](https://help.github.com/en/actions/automating-your-work
If you're using a custom domain and require a `CNAME` file, or if you require the use of a `.nojekyll` file, you can safely commit these files directly into deployment branch without them being overridden after each deployment, additionally you can include these files in your deployment folder to update them. If you need to add additional files to the deployment that should be ignored by the build clean-up steps you can utilize the `clean-exclude` option. If you're using a custom domain and require a `CNAME` file, or if you require the use of a `.nojekyll` file, you can safely commit these files directly into deployment branch without them being overridden after each deployment, additionally you can include these files in your deployment folder to update them. If you need to add additional files to the deployment that should be ignored by the build clean-up steps you can utilize the `clean-exclude` option.
<details><summary>Click here to view an example of this.</summary>
<details><summary>Click here to view an exmaple of this.</summary>
<p> <p>
```yml ```yml
@ -346,6 +345,6 @@ If you wish to remove these files you must go into the deployment branch directl
## Support 💖 ## Support 💖
This project would not be possible without all of our fantastic [contributors](https://github.com/JamesIves/github-pages-deploy-action/graphs/contributors). The project logo was created by [Paganini](https://twitter.com/paganiniart). This project would not be possible without all of our fantastic [contributors](https://github.com/JamesIves/github-pages-deploy-action/graphs/contributors).
If you'd like to support the maintenance and upkeep of this project you can [donate via GitHub Sponsors](https://github.com/sponsors/JamesIves). This project is distributed under the [MIT](https://github.com/JamesIves/github-pages-deploy-action/blob/dev/LICENSE) license. If you'd like to support the maintenance and upkeep of this project you can [donate via GitHub Sponsors](https://github.com/sponsors/JamesIves). This project is distributed under the [MIT](https://github.com/JamesIves/github-pages-deploy-action/blob/dev/LICENSE) license, and the project logo was created by [Paganini](https://twitter.com/paganiniart).

View File

@ -11,4 +11,4 @@ The current version is actively maintained and will receive frequent updates and
## Reporting a Vulnerability ## Reporting a Vulnerability
Please disclose any security vulnerabilities either through the issues interface (as a bug) or by [emailing the project maintainer](https://jamesiv.es). Please disclose any security vulnerabilities either through the issues interface (as a bug) or by [emailing the project maintainer](https://jamesiv.es). Please bare in mind that this project is voluntarily maintained and updates will be worked on based on availability.

View File

@ -42,6 +42,7 @@ describe('git', () => {
describe('init', () => { describe('init', () => {
it('should execute commands', async () => { it('should execute commands', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
repositoryPath: 'JamesIves/github-pages-deploy-action', repositoryPath: 'JamesIves/github-pages-deploy-action',
token: '123', token: '123',
@ -64,6 +65,7 @@ describe('git', () => {
}) })
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
repositoryPath: 'JamesIves/github-pages-deploy-action', repositoryPath: 'JamesIves/github-pages-deploy-action',
token: '123', token: '123',
@ -87,6 +89,7 @@ describe('git', () => {
it('should correctly continue when it cannot unset a git config value', async () => { it('should correctly continue when it cannot unset a git config value', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
repositoryPath: 'JamesIves/github-pages-deploy-action', repositoryPath: 'JamesIves/github-pages-deploy-action',
token: '123', token: '123',
@ -108,6 +111,7 @@ describe('git', () => {
process.env.CI = 'true' process.env.CI = 'true'
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
repositoryPath: 'JamesIves/github-pages-deploy-action', repositoryPath: 'JamesIves/github-pages-deploy-action',
sshKey: true, sshKey: true,
@ -128,6 +132,7 @@ describe('git', () => {
it('should correctly continue when it cannot remove origin', async () => { it('should correctly continue when it cannot remove origin', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
repositoryPath: 'JamesIves/github-pages-deploy-action', repositoryPath: 'JamesIves/github-pages-deploy-action',
token: '123', token: '123',
@ -148,6 +153,7 @@ describe('git', () => {
describe('deploy', () => { describe('deploy', () => {
it('should execute commands', async () => { it('should execute commands', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',
@ -170,6 +176,7 @@ describe('git', () => {
it('should not push when asked to dryRun', async () => { it('should not push when asked to dryRun', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
dryRun: true, dryRun: true,
folder: 'assets', folder: 'assets',
@ -192,6 +199,7 @@ describe('git', () => {
it('should execute commands with single commit toggled', async () => { it('should execute commands with single commit toggled', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'other', folder: 'other',
folderPath: 'other', folderPath: 'other',
@ -215,6 +223,7 @@ describe('git', () => {
it('should execute commands with single commit toggled and existing branch', async () => { it('should execute commands with single commit toggled and existing branch', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'other', folder: 'other',
folderPath: 'other', folderPath: 'other',
@ -238,6 +247,7 @@ describe('git', () => {
it('should execute commands with single commit and dryRun toggled', async () => { it('should execute commands with single commit and dryRun toggled', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'other', folder: 'other',
folderPath: 'other', folderPath: 'other',
@ -270,6 +280,7 @@ describe('git', () => {
}) })
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
folderPath: 'assets', folderPath: 'assets',
@ -300,6 +311,7 @@ describe('git', () => {
it('should execute commands with clean options', async () => { it('should execute commands with clean options', async () => {
process.env.GITHUB_SHA = '' process.env.GITHUB_SHA = ''
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'other', folder: 'other',
folderPath: 'other', folderPath: 'other',
@ -324,6 +336,7 @@ describe('git', () => {
it('should execute commands with clean options stored as an array', async () => { it('should execute commands with clean options stored as an array', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
folderPath: 'assets', folderPath: 'assets',
@ -347,6 +360,7 @@ describe('git', () => {
it('should gracefully handle target folder', async () => { it('should gracefully handle target folder', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: '.', folder: '.',
branch: 'branch', branch: 'branch',
@ -367,6 +381,7 @@ describe('git', () => {
it('should stop early if there is nothing to commit', async () => { it('should stop early if there is nothing to commit', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',
@ -390,6 +405,7 @@ describe('git', () => {
}) })
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',

View File

@ -41,6 +41,7 @@ describe('main', () => {
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',
token: '123', token: '123',
hostname: 'github.com',
pusher: { pusher: {
name: 'asd', name: 'asd',
email: 'as@cat' email: 'as@cat'
@ -56,6 +57,7 @@ describe('main', () => {
it('should run through the commands and succeed', async () => { it('should run through the commands and succeed', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
repositoryPath: 'JamesIves/github-pages-deploy-action', repositoryPath: 'JamesIves/github-pages-deploy-action',
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',
@ -75,6 +77,7 @@ describe('main', () => {
it('should throw if an error is encountered', async () => { it('should throw if an error is encountered', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',
token: null, token: null,

View File

@ -43,6 +43,7 @@ describe('configureSSH', () => {
it('should skip client configuration if sshKey is set to true', async () => { it('should skip client configuration if sshKey is set to true', async () => {
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',
@ -67,6 +68,7 @@ describe('configureSSH', () => {
}) })
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',
@ -91,6 +93,7 @@ describe('configureSSH', () => {
}) })
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',
@ -115,6 +118,7 @@ describe('configureSSH', () => {
}) })
Object.assign(action, { Object.assign(action, {
hostname: 'github.com',
silent: false, silent: false,
folder: 'assets', folder: 'assets',
branch: 'branch', branch: 'branch',

View File

@ -5,7 +5,8 @@ import {
generateRepositoryPath, generateRepositoryPath,
generateFolderPath, generateFolderPath,
suppressSensitiveInformation, suppressSensitiveInformation,
checkParameters checkParameters,
stripProtocolFromUrl
} from '../src/util' } from '../src/util'
describe('util', () => { describe('util', () => {
@ -79,11 +80,13 @@ describe('util', () => {
branch: '123', branch: '123',
workspace: 'src/', workspace: 'src/',
folder: 'build', folder: 'build',
hostname: 'github.com',
token: null, token: null,
sshKey: 'real_token', sshKey: 'real_token',
silent: false, silent: false,
isTest: TestFlag.NONE isTest: TestFlag.NONE
} }
expect(generateRepositoryPath(action)).toEqual( expect(generateRepositoryPath(action)).toEqual(
'git@github.com:JamesIves/github-pages-deploy-action' 'git@github.com:JamesIves/github-pages-deploy-action'
) )
@ -95,13 +98,15 @@ describe('util', () => {
branch: '123', branch: '123',
workspace: 'src/', workspace: 'src/',
folder: 'build', folder: 'build',
hostname: 'enterprise.github.com',
token: '123', token: '123',
sshKey: null, sshKey: null,
silent: false, silent: false,
isTest: TestFlag.NONE isTest: TestFlag.NONE
} }
expect(generateRepositoryPath(action)).toEqual( expect(generateRepositoryPath(action)).toEqual(
'https://x-access-token:123@github.com/JamesIves/github-pages-deploy-action.git' 'https://x-access-token:123@enterprise.github.com/JamesIves/github-pages-deploy-action.git'
) )
}) })
@ -302,4 +307,24 @@ describe('util', () => {
} }
}) })
}) })
describe('stripProtocolFromUrl', () => {
it('removes https', () => {
expect(stripProtocolFromUrl('https://github.com')).toBe('github.com')
})
it('removes http', () => {
expect(stripProtocolFromUrl('http://github.com')).toBe('github.com')
})
it('removes https|http and www.', () => {
expect(stripProtocolFromUrl('http://www.github.com')).toBe('github.com')
})
it('works with a url that is not github.com', () => {
expect(stripProtocolFromUrl('http://github.enterprise.jamesiv.es')).toBe(
'github.enterprise.jamesiv.es'
)
})
})
}) })

View File

@ -16,6 +16,7 @@ describe('generateWorktree', () => {
try { try {
await generateWorktree( await generateWorktree(
{ {
hostname: 'github.com',
workspace: 'somewhere', workspace: 'somewhere',
singleCommit: false, singleCommit: false,
branch: 'gh-pages', branch: 'gh-pages',

View File

@ -81,6 +81,7 @@ describe('generateWorktree', () => {
const workspace = clonedir as string const workspace = clonedir as string
await generateWorktree( await generateWorktree(
{ {
hostname: 'github.com',
workspace, workspace,
singleCommit: false, singleCommit: false,
branch: 'gh-pages', branch: 'gh-pages',
@ -111,6 +112,7 @@ describe('generateWorktree', () => {
const workspace = clonedir as string const workspace = clonedir as string
await generateWorktree( await generateWorktree(
{ {
hostname: 'github.com',
workspace, workspace,
singleCommit: false, singleCommit: false,
branch: 'no-pages', branch: 'no-pages',
@ -138,6 +140,7 @@ describe('generateWorktree', () => {
const workspace = clonedir as string const workspace = clonedir as string
await generateWorktree( await generateWorktree(
{ {
hostname: 'github.com',
workspace, workspace,
singleCommit: true, singleCommit: true,
branch: 'gh-pages', branch: 'gh-pages',
@ -169,6 +172,7 @@ describe('generateWorktree', () => {
const workspace = clonedir as string const workspace = clonedir as string
await generateWorktree( await generateWorktree(
{ {
hostname: 'github.com',
workspace, workspace,
singleCommit: true, singleCommit: true,
branch: 'no-pages', branch: 'no-pages',

View File

@ -40,16 +40,16 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "26.0.20", "@types/jest": "26.0.20",
"@types/node": "14.14.25", "@types/node": "14.14.31",
"eslint": "7.19.0", "eslint": "7.20.0",
"eslint-plugin-github": "4.1.1", "eslint-plugin-github": "4.1.1",
"eslint-plugin-jest": "24.1.3", "eslint-plugin-jest": "24.1.5",
"eslint-plugin-prettier": "^3.1.2", "eslint-plugin-prettier": "^3.1.2",
"jest": "25.5.4", "jest": "26.6.3",
"jest-circus": "26.6.3", "jest-circus": "26.6.3",
"prettier": "2.2.1", "prettier": "2.2.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "25.5.1", "ts-jest": "26.5.2",
"typescript": "3.9.7" "typescript": "4.2.2"
} }
} }

View File

@ -1,6 +1,6 @@
import {getInput} from '@actions/core' import {getInput} from '@actions/core'
import * as github from '@actions/github' import * as github from '@actions/github'
import {isNullOrUndefined} from './util' import {isNullOrUndefined, stripProtocolFromUrl} from './util'
const {pusher, repository} = github.context.payload const {pusher, repository} = github.context.payload
@ -25,6 +25,8 @@ export interface ActionInterface {
cleanExclude?: string[] cleanExclude?: string[]
/** If you need to customize the commit message for an integration you can do so. */ /** If you need to customize the commit message for an integration you can do so. */
commitMessage?: string commitMessage?: string
/** The hostname of which the GitHub Workflow is being run on, ie: github.com */
hostname?: string
/** The git config email. */ /** The git config email. */
email?: string email?: string
/** The folder to deploy. */ /** The folder to deploy. */
@ -89,6 +91,9 @@ export const action: ActionInterface = {
cleanExclude: (getInput('clean-exclude') || '') cleanExclude: (getInput('clean-exclude') || '')
.split('\n') .split('\n')
.filter(l => l !== ''), .filter(l => l !== ''),
hostname: process.env.GITHUB_SERVER_URL
? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
: 'github.com',
isTest: TestFlag.NONE, isTest: TestFlag.NONE,
email: !isNullOrUndefined(getInput('git-config-email')) email: !isNullOrUndefined(getInput('git-config-email'))
? getInput('git-config-email') ? getInput('git-config-email')
@ -96,7 +101,11 @@ export const action: ActionInterface = {
? pusher.email ? pusher.email
: `${ : `${
process.env.GITHUB_ACTOR || 'github-pages-deploy-action' process.env.GITHUB_ACTOR || 'github-pages-deploy-action'
}@users.noreply.github.com`, }@users.noreply.${
process.env.GITHUB_SERVER_URL
? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
: 'github.com'
}`,
name: !isNullOrUndefined(getInput('git-config-name')) name: !isNullOrUndefined(getInput('git-config-name'))
? getInput('git-config-name') ? getInput('git-config-name')
: pusher && pusher.name : pusher && pusher.name

View File

@ -29,7 +29,7 @@ export async function init(action: ActionInterface): Promise<void | Error> {
Only runs in the GitHub Actions CI environment if a user is not using an SSH key. Only runs in the GitHub Actions CI environment if a user is not using an SSH key.
*/ */
await execute( await execute(
`git config --local --unset-all http.https://github.com/.extraheader`, `git config --local --unset-all http.https://${action.hostname}/.extraheader`,
action.workspace, action.workspace,
action.silent action.silent
) )

View File

@ -12,10 +12,8 @@ export async function configureSSH(action: ActionInterface): Promise<void> {
const sshKnownHostsDirectory = `${sshDirectory}/known_hosts` const sshKnownHostsDirectory = `${sshDirectory}/known_hosts`
// SSH fingerprints provided by GitHub: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/githubs-ssh-key-fingerprints // SSH fingerprints provided by GitHub: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/githubs-ssh-key-fingerprints
const sshGitHubKnownHostRsa = const sshGitHubKnownHostRsa = `\n${action.hostname} ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n`
'\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n' const sshGitHubKnownHostDss = `\n${action.hostname} ssh-dss AAAAB3NzaC1kc3MAAACBANGFW2P9xlGU3zWrymJgI/lKo//ZW2WfVtmbsUZJ5uyKArtlQOT2+WRhcg4979aFxgKdcsqAYW3/LS1T2km3jYW/vr4Uzn+dXWODVk5VlUiZ1HFOHf6s6ITcZvjvdbp6ZbpM+DuJT7Bw+h5Fx8Qt8I16oCZYmAPJRtu46o9C2zk1AAAAFQC4gdFGcSbp5Gr0Wd5Ay/jtcldMewAAAIATTgn4sY4Nem/FQE+XJlyUQptPWMem5fwOcWtSXiTKaaN0lkk2p2snz+EJvAGXGq9dTSWHyLJSM2W6ZdQDqWJ1k+cL8CARAqL+UMwF84CR0m3hj+wtVGD/J4G5kW2DBAf4/bqzP4469lT+dF2FRQ2L9JKXrCWcnhMtJUvua8dvnwAAAIB6C4nQfAA7x8oLta6tT+oCk2WQcydNsyugE8vLrHlogoWEicla6cWPk7oXSspbzUcfkjN3Qa6e74PhRkc7JdSdAlFzU3m7LMkXo1MHgkqNX8glxWNVqBSc0YRdbFdTkL0C6gtpklilhvuHQCdbgB3LBAikcRkDp+FCVkUgPC/7Rw==\n`
const sshGitHubKnownHostDss =
'\ngithub.com ssh-dss AAAAB3NzaC1kc3MAAACBANGFW2P9xlGU3zWrymJgI/lKo//ZW2WfVtmbsUZJ5uyKArtlQOT2+WRhcg4979aFxgKdcsqAYW3/LS1T2km3jYW/vr4Uzn+dXWODVk5VlUiZ1HFOHf6s6ITcZvjvdbp6ZbpM+DuJT7Bw+h5Fx8Qt8I16oCZYmAPJRtu46o9C2zk1AAAAFQC4gdFGcSbp5Gr0Wd5Ay/jtcldMewAAAIATTgn4sY4Nem/FQE+XJlyUQptPWMem5fwOcWtSXiTKaaN0lkk2p2snz+EJvAGXGq9dTSWHyLJSM2W6ZdQDqWJ1k+cL8CARAqL+UMwF84CR0m3hj+wtVGD/J4G5kW2DBAf4/bqzP4469lT+dF2FRQ2L9JKXrCWcnhMtJUvua8dvnwAAAIB6C4nQfAA7x8oLta6tT+oCk2WQcydNsyugE8vLrHlogoWEicla6cWPk7oXSspbzUcfkjN3Qa6e74PhRkc7JdSdAlFzU3m7LMkXo1MHgkqNX8glxWNVqBSc0YRdbFdTkL0C6gtpklilhvuHQCdbgB3LBAikcRkDp+FCVkUgPC/7Rw==\n'
info(`Configuring SSH client… 🔑`) info(`Configuring SSH client… 🔑`)

View File

@ -18,8 +18,8 @@ export const generateTokenType = (action: ActionInterface): string =>
/* 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 => export const generateRepositoryPath = (action: ActionInterface): string =>
action.sshKey action.sshKey
? `git@github.com:${action.repositoryName}` ? `git@${action.hostname}:${action.repositoryName}`
: `https://${`x-access-token:${action.token}`}@github.com/${ : `https://${`x-access-token:${action.token}`}@${action.hostname}/${
action.repositoryName action.repositoryName
}.git` }.git`
@ -89,3 +89,7 @@ export const suppressSensitiveInformation = (
return value return value
} }
/** Strips the protocol from a provided URL. */
export const stripProtocolFromUrl = (url: string): string =>
url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').split('/')[0]

1109
yarn.lock

File diff suppressed because it is too large Load Diff