mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Merge branch 'dev' into releases/v4
This commit is contained in:
commit
45f4c85b30
18
.github/workflows/codeql-analysis.yml
vendored
18
.github/workflows/codeql-analysis.yml
vendored
@ -6,7 +6,6 @@ on:
|
||||
- 'dev-v*'
|
||||
- 'releases/v*'
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches:
|
||||
- dev
|
||||
- 'dev-v*'
|
||||
@ -22,28 +21,11 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
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
|
||||
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
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
21
.github/workflows/deploy.yml
vendored
Normal file
21
.github/workflows/deploy.yml
vendored
Normal 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
|
20
.github/workflows/integration.yml
vendored
20
.github/workflows/integration.yml
vendored
@ -1,12 +1,17 @@
|
||||
name: integration-tests
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch:
|
||||
description: 'Specifies the branch which the integration tests should run on.'
|
||||
required: true
|
||||
default: 'releases/v4'
|
||||
schedule:
|
||||
- cron: 30 15 * * 0-6
|
||||
push:
|
||||
tags-ignore:
|
||||
- '*.*'
|
||||
branches:
|
||||
- dev
|
||||
- releases/v4
|
||||
|
||||
jobs:
|
||||
@ -22,12 +27,13 @@ jobs:
|
||||
with:
|
||||
git-config-name: Montezuma
|
||||
git-config-email: montezuma@jamesiv.es
|
||||
repository-name: JamesIves/lab
|
||||
repository-name: MontezumaIves/lab
|
||||
token: ${{ secrets.ACCESS_TOKEN }}
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
single-commit: true
|
||||
clean: true
|
||||
silent: true
|
||||
|
||||
# Deploys using checkout@v1 with an ACCESS_TOKEN.
|
||||
integration-checkout-v1:
|
||||
@ -46,6 +52,7 @@ jobs:
|
||||
target-folder: cat/montezuma
|
||||
git-config-name: Montezuma
|
||||
git-config-email: montezuma@jamesiv.es
|
||||
silent: true
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -69,6 +76,7 @@ jobs:
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target-folder: cat/montezuma2
|
||||
silent: true
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -101,6 +109,7 @@ jobs:
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target-folder: cat/montezuma2
|
||||
silent: true
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -125,6 +134,7 @@ jobs:
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target-folder: cat/montezuma3
|
||||
silent: true
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -150,10 +160,11 @@ jobs:
|
||||
- name: Build and Deploy
|
||||
uses: JamesIves/github-pages-deploy-action@releases/v4
|
||||
with:
|
||||
ssh: true
|
||||
ssh-key: true
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target-folder: cat/montezuma4
|
||||
silent: true
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -182,6 +193,7 @@ jobs:
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target-folder: cat/montezuma4
|
||||
silent: true
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -206,6 +218,7 @@ jobs:
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
clean: true
|
||||
silent: true
|
||||
|
||||
# Deploys to a branch that doesn't exist with SINGLE_COMMIT.
|
||||
integration-branch-creation:
|
||||
@ -224,6 +237,7 @@ jobs:
|
||||
branch: integration-test-delete-prod
|
||||
folder: integration
|
||||
single-commit: true
|
||||
silent: true
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
|
2
.github/workflows/production.yml
vendored
2
.github/workflows/production.yml
vendored
@ -9,7 +9,7 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build production
|
||||
name: Build Production
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
11
.github/workflows/publish.yml
vendored
11
.github/workflows/publish.yml
vendored
@ -1,7 +1,10 @@
|
||||
name: publish-to-npm
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'The updated registry version number.'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -18,7 +21,7 @@ jobs:
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
scope: '@jamesives'
|
||||
|
||||
- name: Configure git
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config user.email "iam@jamesiv.es"
|
||||
git config user.name "James Ives"
|
||||
@ -28,7 +31,7 @@ jobs:
|
||||
|
||||
- run: yarn install --frozen-lockfile
|
||||
- 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
|
||||
|
||||
# Publish to npm
|
||||
|
4
LICENSE
4
LICENSE
@ -1,6 +1,6 @@
|
||||
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
|
||||
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
|
||||
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
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
|
13
README.md
13
README.md
@ -31,7 +31,7 @@
|
||||
</p>
|
||||
|
||||
<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 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 |
|
||||
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- |
|
||||
| `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** |
|
||||
|
||||
#### 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** |
|
||||
| `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** |
|
||||
| `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** |
|
||||
| `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** |
|
||||
@ -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.
|
||||
|
||||
|
||||
<details><summary>Click here to view an exmaple of this.</summary>
|
||||
<details><summary>Click here to view an example of this.</summary>
|
||||
<p>
|
||||
|
||||
```yml
|
||||
@ -346,6 +345,6 @@ If you wish to remove these files you must go into the deployment branch directl
|
||||
|
||||
## 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).
|
||||
|
@ -11,4 +11,4 @@ The current version is actively maintained and will receive frequent updates and
|
||||
|
||||
## 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.
|
||||
|
@ -42,6 +42,7 @@ describe('git', () => {
|
||||
describe('init', () => {
|
||||
it('should execute commands', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
repositoryPath: 'JamesIves/github-pages-deploy-action',
|
||||
token: '123',
|
||||
@ -64,6 +65,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
repositoryPath: 'JamesIves/github-pages-deploy-action',
|
||||
token: '123',
|
||||
@ -87,6 +89,7 @@ describe('git', () => {
|
||||
|
||||
it('should correctly continue when it cannot unset a git config value', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
repositoryPath: 'JamesIves/github-pages-deploy-action',
|
||||
token: '123',
|
||||
@ -108,6 +111,7 @@ describe('git', () => {
|
||||
process.env.CI = 'true'
|
||||
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
repositoryPath: 'JamesIves/github-pages-deploy-action',
|
||||
sshKey: true,
|
||||
@ -128,6 +132,7 @@ describe('git', () => {
|
||||
|
||||
it('should correctly continue when it cannot remove origin', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
repositoryPath: 'JamesIves/github-pages-deploy-action',
|
||||
token: '123',
|
||||
@ -148,6 +153,7 @@ describe('git', () => {
|
||||
describe('deploy', () => {
|
||||
it('should execute commands', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
@ -170,6 +176,7 @@ describe('git', () => {
|
||||
|
||||
it('should not push when asked to dryRun', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
dryRun: true,
|
||||
folder: 'assets',
|
||||
@ -192,6 +199,7 @@ describe('git', () => {
|
||||
|
||||
it('should execute commands with single commit toggled', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'other',
|
||||
folderPath: 'other',
|
||||
@ -215,6 +223,7 @@ describe('git', () => {
|
||||
|
||||
it('should execute commands with single commit toggled and existing branch', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'other',
|
||||
folderPath: 'other',
|
||||
@ -238,6 +247,7 @@ describe('git', () => {
|
||||
|
||||
it('should execute commands with single commit and dryRun toggled', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'other',
|
||||
folderPath: 'other',
|
||||
@ -270,6 +280,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
folderPath: 'assets',
|
||||
@ -300,6 +311,7 @@ describe('git', () => {
|
||||
it('should execute commands with clean options', async () => {
|
||||
process.env.GITHUB_SHA = ''
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'other',
|
||||
folderPath: 'other',
|
||||
@ -324,6 +336,7 @@ describe('git', () => {
|
||||
|
||||
it('should execute commands with clean options stored as an array', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
folderPath: 'assets',
|
||||
@ -347,6 +360,7 @@ describe('git', () => {
|
||||
|
||||
it('should gracefully handle target folder', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: '.',
|
||||
branch: 'branch',
|
||||
@ -367,6 +381,7 @@ describe('git', () => {
|
||||
|
||||
it('should stop early if there is nothing to commit', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
@ -390,6 +405,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
|
@ -41,6 +41,7 @@ describe('main', () => {
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
token: '123',
|
||||
hostname: 'github.com',
|
||||
pusher: {
|
||||
name: 'asd',
|
||||
email: 'as@cat'
|
||||
@ -56,6 +57,7 @@ describe('main', () => {
|
||||
|
||||
it('should run through the commands and succeed', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
repositoryPath: 'JamesIves/github-pages-deploy-action',
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
@ -75,6 +77,7 @@ describe('main', () => {
|
||||
|
||||
it('should throw if an error is encountered', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
token: null,
|
||||
|
@ -43,6 +43,7 @@ describe('configureSSH', () => {
|
||||
|
||||
it('should skip client configuration if sshKey is set to true', async () => {
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
@ -67,6 +68,7 @@ describe('configureSSH', () => {
|
||||
})
|
||||
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
@ -91,6 +93,7 @@ describe('configureSSH', () => {
|
||||
})
|
||||
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
@ -115,6 +118,7 @@ describe('configureSSH', () => {
|
||||
})
|
||||
|
||||
Object.assign(action, {
|
||||
hostname: 'github.com',
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
|
@ -5,7 +5,8 @@ import {
|
||||
generateRepositoryPath,
|
||||
generateFolderPath,
|
||||
suppressSensitiveInformation,
|
||||
checkParameters
|
||||
checkParameters,
|
||||
stripProtocolFromUrl
|
||||
} from '../src/util'
|
||||
|
||||
describe('util', () => {
|
||||
@ -79,11 +80,13 @@ describe('util', () => {
|
||||
branch: '123',
|
||||
workspace: 'src/',
|
||||
folder: 'build',
|
||||
hostname: 'github.com',
|
||||
token: null,
|
||||
sshKey: 'real_token',
|
||||
silent: false,
|
||||
isTest: TestFlag.NONE
|
||||
}
|
||||
|
||||
expect(generateRepositoryPath(action)).toEqual(
|
||||
'git@github.com:JamesIves/github-pages-deploy-action'
|
||||
)
|
||||
@ -95,13 +98,15 @@ describe('util', () => {
|
||||
branch: '123',
|
||||
workspace: 'src/',
|
||||
folder: 'build',
|
||||
hostname: 'enterprise.github.com',
|
||||
token: '123',
|
||||
sshKey: null,
|
||||
silent: false,
|
||||
isTest: TestFlag.NONE
|
||||
}
|
||||
|
||||
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'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -16,6 +16,7 @@ describe('generateWorktree', () => {
|
||||
try {
|
||||
await generateWorktree(
|
||||
{
|
||||
hostname: 'github.com',
|
||||
workspace: 'somewhere',
|
||||
singleCommit: false,
|
||||
branch: 'gh-pages',
|
||||
|
@ -81,6 +81,7 @@ describe('generateWorktree', () => {
|
||||
const workspace = clonedir as string
|
||||
await generateWorktree(
|
||||
{
|
||||
hostname: 'github.com',
|
||||
workspace,
|
||||
singleCommit: false,
|
||||
branch: 'gh-pages',
|
||||
@ -111,6 +112,7 @@ describe('generateWorktree', () => {
|
||||
const workspace = clonedir as string
|
||||
await generateWorktree(
|
||||
{
|
||||
hostname: 'github.com',
|
||||
workspace,
|
||||
singleCommit: false,
|
||||
branch: 'no-pages',
|
||||
@ -138,6 +140,7 @@ describe('generateWorktree', () => {
|
||||
const workspace = clonedir as string
|
||||
await generateWorktree(
|
||||
{
|
||||
hostname: 'github.com',
|
||||
workspace,
|
||||
singleCommit: true,
|
||||
branch: 'gh-pages',
|
||||
@ -169,6 +172,7 @@ describe('generateWorktree', () => {
|
||||
const workspace = clonedir as string
|
||||
await generateWorktree(
|
||||
{
|
||||
hostname: 'github.com',
|
||||
workspace,
|
||||
singleCommit: true,
|
||||
branch: 'no-pages',
|
||||
|
12
package.json
12
package.json
@ -40,16 +40,16 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "26.0.20",
|
||||
"@types/node": "14.14.25",
|
||||
"eslint": "7.19.0",
|
||||
"@types/node": "14.14.31",
|
||||
"eslint": "7.20.0",
|
||||
"eslint-plugin-github": "4.1.1",
|
||||
"eslint-plugin-jest": "24.1.3",
|
||||
"eslint-plugin-jest": "24.1.5",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"jest": "25.5.4",
|
||||
"jest": "26.6.3",
|
||||
"jest-circus": "26.6.3",
|
||||
"prettier": "2.2.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "25.5.1",
|
||||
"typescript": "3.9.7"
|
||||
"ts-jest": "26.5.2",
|
||||
"typescript": "4.2.2"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {getInput} from '@actions/core'
|
||||
import * as github from '@actions/github'
|
||||
import {isNullOrUndefined} from './util'
|
||||
import {isNullOrUndefined, stripProtocolFromUrl} from './util'
|
||||
|
||||
const {pusher, repository} = github.context.payload
|
||||
|
||||
@ -25,6 +25,8 @@ export interface ActionInterface {
|
||||
cleanExclude?: string[]
|
||||
/** If you need to customize the commit message for an integration you can do so. */
|
||||
commitMessage?: string
|
||||
/** The hostname of which the GitHub Workflow is being run on, ie: github.com */
|
||||
hostname?: string
|
||||
/** The git config email. */
|
||||
email?: string
|
||||
/** The folder to deploy. */
|
||||
@ -89,6 +91,9 @@ export const action: ActionInterface = {
|
||||
cleanExclude: (getInput('clean-exclude') || '')
|
||||
.split('\n')
|
||||
.filter(l => l !== ''),
|
||||
hostname: process.env.GITHUB_SERVER_URL
|
||||
? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
|
||||
: 'github.com',
|
||||
isTest: TestFlag.NONE,
|
||||
email: !isNullOrUndefined(getInput('git-config-email'))
|
||||
? getInput('git-config-email')
|
||||
@ -96,7 +101,11 @@ export const action: ActionInterface = {
|
||||
? pusher.email
|
||||
: `${
|
||||
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'))
|
||||
? getInput('git-config-name')
|
||||
: pusher && pusher.name
|
||||
|
@ -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.
|
||||
*/
|
||||
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.silent
|
||||
)
|
||||
|
@ -12,10 +12,8 @@ export async function configureSSH(action: ActionInterface): Promise<void> {
|
||||
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
|
||||
const sshGitHubKnownHostRsa =
|
||||
'\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\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'
|
||||
const sshGitHubKnownHostRsa = `\n${action.hostname} 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`
|
||||
|
||||
info(`Configuring SSH client… 🔑`)
|
||||
|
||||
|
@ -18,8 +18,8 @@ export const generateTokenType = (action: ActionInterface): string =>
|
||||
/* Generates a the repository path used to make the commits. */
|
||||
export const generateRepositoryPath = (action: ActionInterface): string =>
|
||||
action.sshKey
|
||||
? `git@github.com:${action.repositoryName}`
|
||||
: `https://${`x-access-token:${action.token}`}@github.com/${
|
||||
? `git@${action.hostname}:${action.repositoryName}`
|
||||
: `https://${`x-access-token:${action.token}`}@${action.hostname}/${
|
||||
action.repositoryName
|
||||
}.git`
|
||||
|
||||
@ -89,3 +89,7 @@ export const suppressSensitiveInformation = (
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
/** Strips the protocol from a provided URL. */
|
||||
export const stripProtocolFromUrl = (url: string): string =>
|
||||
url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').split('/')[0]
|
||||
|
Loading…
Reference in New Issue
Block a user