mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
* Hyphenate inputs and outputs, add step output, fix #558 I've also tried to make the clean docs a bit clearer, and consistent about clean being on my default. Still not totally happy with the intro of the docs there, though. * Add testing of step outputs to build integration tests
This commit is contained in:
parent
7bf80b4b88
commit
291c5c792e
27
.github/workflows/build.yml
vendored
27
.github/workflows/build.yml
vendored
@ -91,12 +91,22 @@ jobs:
|
||||
name: dist
|
||||
|
||||
- name: Deploy
|
||||
id: unmodified
|
||||
uses: ./
|
||||
with:
|
||||
folder: integration
|
||||
branch: ${{ matrix.branch }}
|
||||
SINGLE_COMMIT: ${{ matrix.commit == 'singleCommit' }}
|
||||
dry_run: true
|
||||
single-commit: ${{ matrix.commit == 'singleCommit' }}
|
||||
dry-run: true
|
||||
|
||||
# Usually, this should be skipped, but if the upstream gh-pages
|
||||
# branch doesn't match ours, it should still be a success.
|
||||
- name: Check step output
|
||||
run: |
|
||||
[[ \
|
||||
${{steps.unmodified.outputs.deployment-status}} = skipped || \
|
||||
${{steps.unmodified.outputs.deployment-status}} = success \
|
||||
]]
|
||||
|
||||
- name: Tweak content to publish to existing branch
|
||||
if: ${{ matrix.branch == 'gh-pages' }}
|
||||
@ -104,10 +114,19 @@ jobs:
|
||||
echo "<!-- just sayin -->" >> integration/index.html
|
||||
|
||||
- name: Deploy with modifications to existing branch
|
||||
id: modified
|
||||
uses: ./
|
||||
if: ${{ matrix.branch == 'gh-pages' }}
|
||||
with:
|
||||
folder: integration
|
||||
branch: ${{ matrix.branch }}
|
||||
single_commit: ${{ matrix.commit == 'singleCommit' }}
|
||||
dry_run: true
|
||||
single-commit: ${{ matrix.commit == 'singleCommit' }}
|
||||
dry-run: true
|
||||
|
||||
# The modified deployment should be a success, and not skipped.
|
||||
- name: Check step output
|
||||
if: ${{ matrix.branch == 'gh-pages' }}
|
||||
run: |
|
||||
[[ \
|
||||
${{steps.modified.outputs.deployment-status}} = success \
|
||||
]]
|
||||
|
16
.github/workflows/integration.yml
vendored
16
.github/workflows/integration.yml
vendored
@ -23,9 +23,9 @@ jobs:
|
||||
token: ${{ secrets.ACCESS_TOKEN }}
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target_folder: cat/montezuma
|
||||
git_config_name: Montezuma
|
||||
git_config_email: montezuma@jamesiv.es
|
||||
target-folder: cat/montezuma
|
||||
git-config-name: Montezuma
|
||||
git-config-email: montezuma@jamesiv.es
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -48,7 +48,7 @@ jobs:
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target_folder: cat/montezuma2
|
||||
target-folder: cat/montezuma2
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -80,7 +80,7 @@ jobs:
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target_folder: cat/montezuma2
|
||||
target-folder: cat/montezuma2
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -109,7 +109,7 @@ jobs:
|
||||
ssh: true
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target_folder: cat/montezuma3
|
||||
target-folder: cat/montezuma3
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -142,7 +142,7 @@ jobs:
|
||||
ssh: true
|
||||
branch: gh-pages
|
||||
folder: integration
|
||||
target_folder: cat/montezuma4
|
||||
target-folder: cat/montezuma4
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
@ -184,7 +184,7 @@ jobs:
|
||||
token: ${{ secrets.ACCESS_TOKEN }}
|
||||
branch: integration-test-delete-prod
|
||||
folder: integration
|
||||
single_commit: true
|
||||
single-commit: true
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
uses: dawidd6/action-delete-branch@v2.0.1
|
||||
|
18
README.md
18
README.md
@ -138,15 +138,15 @@ 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. | `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** |
|
||||
| `clean` | If your project generates hashed files on build you can use this option to automatically delete them from 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** |
|
||||
| `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. | `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** |
|
||||
| `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** |
|
||||
| `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** |
|
||||
| `dry-run` | Do not actually push back, but use `--dry-run` on `git push` invocations insead. | `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** |
|
||||
|
||||
@ -162,6 +162,8 @@ The action will export an environment variable called `deployment_status` that y
|
||||
| `failed` | The `failed` status indicates that the action encountered an error while trying to deploy. |
|
||||
| `skipped` | The `skipped` status indicates that the action exited early as there was nothing new to deploy. |
|
||||
|
||||
This value is also set as a step output as `deployment-status`.
|
||||
|
||||
---
|
||||
|
||||
### Using an SSH Deploy Key 🔑
|
||||
|
@ -18,6 +18,7 @@ jest.mock('fs', () => ({
|
||||
jest.mock('@actions/core', () => ({
|
||||
setFailed: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
isDebug: jest.fn(),
|
||||
info: jest.fn()
|
||||
}))
|
||||
|
@ -24,6 +24,7 @@ jest.mock('@actions/io', () => ({
|
||||
jest.mock('@actions/core', () => ({
|
||||
setFailed: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
isDebug: jest.fn(),
|
||||
info: jest.fn()
|
||||
|
36
action.yml
36
action.yml
@ -8,11 +8,11 @@ branding:
|
||||
icon: 'git-commit'
|
||||
color: 'orange'
|
||||
inputs:
|
||||
SSH:
|
||||
ssh:
|
||||
description: 'You can configure the action to deploy using SSH by setting this option to true. More more information on how to add your ssh key pair please refer to the Using a Deploy Key section of this README.'
|
||||
required: false
|
||||
|
||||
TOKEN:
|
||||
token:
|
||||
description: >
|
||||
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.
|
||||
@ -25,59 +25,59 @@ inputs:
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
|
||||
BRANCH:
|
||||
branch:
|
||||
description: 'This is the branch you wish to deploy to, for example gh-pages or docs.'
|
||||
required: true
|
||||
|
||||
FOLDER:
|
||||
folder:
|
||||
description: 'The folder in your repository that you want to deploy. If your build script compiles into a directory named build you would put it here. Folder paths cannot have a leading / or ./. If you wish to deploy the root directory you can place a . here.'
|
||||
required: true
|
||||
|
||||
TARGET_FOLDER:
|
||||
target-folder:
|
||||
description: 'If you would like to push the contents of the deployment folder into a specific directory on the deployment branch you can specify it here.'
|
||||
required: false
|
||||
|
||||
COMMIT_MESSAGE:
|
||||
commit-message:
|
||||
description: 'If you need to customize the commit message for an integration you can do so.'
|
||||
required: false
|
||||
|
||||
CLEAN:
|
||||
description: 'If your project generates hashed files on build you can use this option to automatically delete them from the deployment branch with each deploy. This option can be toggled on by setting it to true.'
|
||||
clean:
|
||||
description: '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 on by default and can be toggled off by setting it to false.'
|
||||
required: false
|
||||
default: 'true'
|
||||
default: true
|
||||
|
||||
clean-exclude:
|
||||
description: "If you need to use CLEAN but you would 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."
|
||||
description: "If you need to use clean but you would 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."
|
||||
required: false
|
||||
|
||||
DRY_RUN:
|
||||
dry-run:
|
||||
description: "Do not actually push back, but use `--dry-run` on `git push` invocations insead."
|
||||
required: false
|
||||
|
||||
GIT_CONFIG_NAME:
|
||||
git-config-name:
|
||||
description: "Allows you to customize the name that is attached to the GitHub 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."
|
||||
required: false
|
||||
|
||||
GIT_CONFIG_EMAIL:
|
||||
git-config-email:
|
||||
description: "Allows you to customize the email that is attached to the GitHub 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."
|
||||
required: false
|
||||
|
||||
REPOSITORY_NAME:
|
||||
repository-name:
|
||||
description: "Allows you to speicfy a different repository path so long as you have permissions to push to it. This should be formatted like so: JamesIves/github-pages-deploy-action"
|
||||
required: false
|
||||
|
||||
WORKSPACE:
|
||||
workspace:
|
||||
description: "This should point to where your project lives on the virtual machine. The GitHub Actions environment will set this for you. It is only neccersary to set this variable if you're using the node module."
|
||||
required: false
|
||||
|
||||
SINGLE_COMMIT:
|
||||
single-commit:
|
||||
description: "This option can be used if you'd prefer to have a single commit on the deployment branch instead of maintaining the full history."
|
||||
required: false
|
||||
|
||||
SILENT:
|
||||
silent:
|
||||
description: "Silences the action output preventing it from displaying git messages."
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
DEPLOYMENT_STATUS:
|
||||
deployment-status:
|
||||
description: 'The status of the deployment that indicates if the run failed or passed. Possible outputs include: success|failed|skipped'
|
||||
|
@ -76,9 +76,9 @@ export interface NodeActionInterface {
|
||||
export const action: ActionInterface = {
|
||||
folder: getInput('folder'),
|
||||
branch: getInput('branch'),
|
||||
commitMessage: getInput('commit_message'),
|
||||
dryRun: !isNullOrUndefined(getInput('dry_run'))
|
||||
? getInput('dry_run').toLowerCase() === 'true'
|
||||
commitMessage: getInput('commit-message'),
|
||||
dryRun: !isNullOrUndefined(getInput('dry-run'))
|
||||
? getInput('dry-run').toLowerCase() === 'true'
|
||||
: false,
|
||||
clean: !isNullOrUndefined(getInput('clean'))
|
||||
? getInput('clean').toLowerCase() === 'true'
|
||||
@ -87,28 +87,28 @@ export const action: ActionInterface = {
|
||||
.split('\n')
|
||||
.filter(l => l !== ''),
|
||||
isTest: TestFlag.NONE,
|
||||
email: !isNullOrUndefined(getInput('git_config_email'))
|
||||
? getInput('git_config_email')
|
||||
email: !isNullOrUndefined(getInput('git-config-email'))
|
||||
? getInput('git-config-email')
|
||||
: pusher && pusher.email
|
||||
? pusher.email
|
||||
: `${
|
||||
process.env.GITHUB_ACTOR || 'github-pages-deploy-action'
|
||||
}@users.noreply.github.com`,
|
||||
name: !isNullOrUndefined(getInput('git_config_name'))
|
||||
? getInput('git_config_name')
|
||||
name: !isNullOrUndefined(getInput('git-config-name'))
|
||||
? getInput('git-config-name')
|
||||
: pusher && pusher.name
|
||||
? pusher.name
|
||||
: process.env.GITHUB_ACTOR
|
||||
? process.env.GITHUB_ACTOR
|
||||
: 'GitHub Pages Deploy Action',
|
||||
repositoryName: !isNullOrUndefined(getInput('repository_name'))
|
||||
? getInput('repository_name')
|
||||
repositoryName: !isNullOrUndefined(getInput('repository-name'))
|
||||
? getInput('repository-name')
|
||||
: repository && repository.full_name
|
||||
? repository.full_name
|
||||
: process.env.GITHUB_REPOSITORY,
|
||||
token: getInput('token'),
|
||||
singleCommit: !isNullOrUndefined(getInput('single_commit'))
|
||||
? getInput('single_commit').toLowerCase() === 'true'
|
||||
singleCommit: !isNullOrUndefined(getInput('single-commit'))
|
||||
? getInput('single-commit').toLowerCase() === 'true'
|
||||
: false,
|
||||
silent: !isNullOrUndefined(getInput('silent'))
|
||||
? getInput('silent').toLowerCase() === 'true'
|
||||
@ -116,7 +116,7 @@ export const action: ActionInterface = {
|
||||
ssh: !isNullOrUndefined(getInput('ssh'))
|
||||
? getInput('ssh').toLowerCase() === 'true'
|
||||
: false,
|
||||
targetFolder: getInput('target_folder'),
|
||||
targetFolder: getInput('target-folder'),
|
||||
workspace: process.env.GITHUB_WORKSPACE || ''
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {exportVariable, info, setFailed} from '@actions/core'
|
||||
import {exportVariable, info, setFailed, setOutput} from '@actions/core'
|
||||
import {ActionInterface, Status, NodeActionInterface} from './constants'
|
||||
import {deploy, init} from './git'
|
||||
import {
|
||||
@ -60,5 +60,6 @@ export default async function run(
|
||||
)
|
||||
|
||||
exportVariable('deployment_status', status)
|
||||
setOutput('deployment-status', status)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user