Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifies Token Setup #530

Merged
merged 10 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ jobs:
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: build # The folder the action should deploy.
CLEAN: true # Automatically remove deleted files from the deploy branch
```

If you'd like to make it so the workflow only triggers on push events to specific branches then you can modify the `on` section.
Expand Down Expand Up @@ -105,7 +103,7 @@ Calling the functions directly will require you to pass in an object containing
import run from "github-pages-deploy-action";

run({
accessToken: process.env["ACCESS_TOKEN"],
token: process.env["ACCESS_TOKEN"],
branch: "gh-pages",
folder: "build",
repositoryName: "JamesIves/github-pages-deploy-action",
Expand All @@ -122,28 +120,27 @@ The `with` portion of the workflow **must** be configured before the action will

#### Required Setup

One of the following deployment options must be configured.

| Key | Value Information | Type | Required |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- |
| `GITHUB_TOKEN` | In order for GitHub to trigger the rebuild of your page you must provide the action with the repository's provided GitHub token. This can be referenced in the workflow `yml` file by using `${{ secrets.GITHUB_TOKEN }}`. If you experience any issues with your changes not being reflected after the deployment it may be neccersary to use either the `SSH` or `ACCESS_TOKEN` options. | `secrets / with` | **Yes** |
| `SSH` | You can configure the action to deploy using SSH by setting this option to `true`. For more information on how to add your 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` | **Yes** |
| `ACCESS_TOKEN` | Depending on the repository's permissions you may need to provide the action with a GitHub personal access token instead of the provided GitHub token in order to deploy. You can [learn more about how to generate one here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). **This should be stored as a secret**. | `secrets / with` | **Yes** |

In addition to the deployment options you must also configure the following.
The following options must be configured in order to make a deployment.

| Key | Value Information | Type | Required |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- |
| `BRANCH` | This is the branch you wish to deploy to, for example `gh-pages` or `docs`. | `with` | **Yes** |
| `FOLDER` | The folder in your repository that you want to deploy. If your build script compiles into a directory named `build` you'd put it here. If you wish to deploy the root directory you can place a `.` here. You can also utilize absolute file paths by appending `~` to your folder path. | `with` | **Yes** |

By default the action does not need any token configuration and uses the provided repository scoped GitHub token to make the deployment. If you require most customization you can modify the deployment type using the following options.

| 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) | **No** |
| `SSH` | You can configure the action to deploy using SSH by setting this option to `true`. For more information on how to add your 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

| 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 an `ACCESS_TOKEN` for this configuration option to work properly. | `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** |
Expand Down
24 changes: 12 additions & 12 deletions __tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('git', () => {
Object.assign(action, {
silent: false,
repositoryPath: 'JamesIves/github-pages-deploy-action',
accessToken: '123',
token: '123',
branch: 'branch',
folder: '.',
isTest: true,
Expand All @@ -67,7 +67,7 @@ describe('git', () => {
it('should execute five commands', async () => {
Object.assign(action, {
silent: false,
accessToken: '123',
token: '123',
branch: 'branch',
folder: '.',
pusher: {
Expand All @@ -87,7 +87,7 @@ describe('git', () => {

Object.assign(action, {
silent: false,
accessToken: '123',
token: '123',
branch: 'branch',
folder: '.',
pusher: {
Expand All @@ -112,7 +112,7 @@ describe('git', () => {
silent: false,
folder: 'assets',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand All @@ -139,7 +139,7 @@ describe('git', () => {
dryRun: true,
folder: 'assets',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand All @@ -166,7 +166,7 @@ describe('git', () => {
folder: 'other',
folderPath: 'other',
branch: 'branch',
gitHubToken: '123',
token: '123',
singleCommit: true,
pusher: {
name: 'asd',
Expand All @@ -188,7 +188,7 @@ describe('git', () => {
folder: 'assets',
folderPath: 'assets',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand All @@ -214,7 +214,7 @@ describe('git', () => {
folder: 'other',
folderPath: 'other',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand All @@ -237,7 +237,7 @@ describe('git', () => {
folder: 'assets',
folderPath: 'assets',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand All @@ -258,7 +258,7 @@ describe('git', () => {
silent: false,
folder: '.',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {},
clean: true,
targetFolder: 'new_folder',
Expand All @@ -279,7 +279,7 @@ describe('git', () => {
silent: false,
folder: 'assets',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand All @@ -302,7 +302,7 @@ describe('git', () => {
silent: false,
folder: 'assets',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand Down
7 changes: 3 additions & 4 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('main', () => {
repositoryPath: 'JamesIves/github-pages-deploy-action',
folder: 'assets',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand All @@ -58,7 +58,7 @@ describe('main', () => {
repositoryPath: 'JamesIves/github-pages-deploy-action',
folder: 'assets',
branch: 'branch',
gitHubToken: '123',
token: '123',
pusher: {
name: 'asd',
email: 'as@cat'
Expand All @@ -74,9 +74,8 @@ describe('main', () => {
Object.assign(action, {
folder: 'assets',
branch: 'branch',
gitHubToken: null,
token: null,
ssh: null,
accessToken: null,
pusher: {
name: 'asd',
email: 'as@cat'
Expand Down
Loading