Skip to content

Commit

Permalink
Switch to personal access token only
Browse files Browse the repository at this point in the history
  • Loading branch information
John Ouellet committed Oct 14, 2021
1 parent d336ce0 commit 4f9d54e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
id: test_action
uses: ./
with:
github_token: ${{ secrets.TRANSFER_ISSUE_TOKEN }}
pat_token: ${{ secrets.TRANSFER_ISSUE_TOKEN }}
labels_file_path: '.github/transfer-issue-labels.yml'
map_repo_labels_file_path: '.github/transfer-issue-map-repo-labels.yml'
- name: Echo Output Data
Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ A GitHub Action for transferring issues between github repos. It also has the a

Input | Description | Required | Default |
----------|-------------|:----------:|:-------:|
| `pat_token` | The GitHub [Perosnal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) created with repo access. | yes | - |
| `destination_repo` | The destination repo. | yes* |-|
| `github_token` | The GitHub token used to create an authenticated client. | no | `${{github.token}}` |
| `create_stub` | Create a stub issue with title and description in original repo. | no | `true` |
| `labels_file_path` | Create labels if it doesn't exist in the transferred repo and tag the transferred issue. | no |-|
| `map_repo_labels_file_path` | Maps the triggering label to a file keyed `label:destination_repo`. If the label is found, it will transfer the issue to that repo. If not, it will exit the process and not tranfer any issue. | yes* |-|

_Note: You must have either `destination_repo` or `map_repo_labels_file_path` set in your action. If not, it will throw an error._
### Input Notes

* You must have either `destination_repo` or `map_repo_labels_file_path` set in your action. If not, it will throw an error.
* The `GITHUB_TOKEN` provided by GitHub Actions will not work when transferring issue to another repo. You will get the error `Resource not accessible by integration` if you try and use it. Create a PAT with the repo check box and all its sub items checked.

## Outputs

Output | Type | Description |
----------|-------------|:----------:|
----------|-------------|------------|
| `transferred_issue_number` | String | The issue number of the transferred issue |
| `transferred_issue_url` | String | The issue url of the transferred issue |
| `transferred_repo` | String | The name of the destination repo |
Expand All @@ -37,8 +40,9 @@ This will send the issue in a `lando` org repo to `lando/transfer-repo`

```
- name: Transfer Issue & Create Stub
uses: lando/transfer-issue-action@1.2.0
uses: lando/transfer-issue-action@1.3.0
with:
pat_token: ${{ secrets.TRANSFER_ISSUE_TOKEN }}
destination_repo: 'transfer-repo'
```

Expand All @@ -48,8 +52,9 @@ Set a file path for the labels yaml file to create labels and tag them on the is

```
- name: Transfer Issue & Create Stub
uses: lando/transfer-issue-action@1.2.0
uses: lando/transfer-issue-action@1.3.0
with:
pat_token: ${{ secrets.TRANSFER_ISSUE_TOKEN }}
destination_repo: 'transfer-repo'
labels_file_path: '.github/transfer-issue-labels.yml'
```
Expand All @@ -69,8 +74,9 @@ This will use our yml file to check tags to dtermine which repos to send them to

```
- name: Transfer Issue & Create Stub
uses: lando/transfer-issue-action@1.2.0
uses: lando/transfer-issue-action@1.3.0
with:
pat_token: ${{ secrets.TRANSFER_ISSUE_TOKEN }}
map_repo_labels_file_path: '.github/transfer-issue-map-repo-labels.yml'
```

Expand All @@ -85,15 +91,15 @@ trill: tronic

## Advanced Example

In this example, we are using our own [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) for authentication. We are also not creating a stub and just adding a comment to the tranferred issue via [https://github.com/actions/github-script](https://github.com/actions/github-script).
In this example, we are not creating a stub and just adding a comment to the tranferred issue via [https://github.com/actions/github-script](https://github.com/actions/github-script).

```
- name: Transfer Issue & Create Stub
uses: lando/transfer-issue-action@1.2.0
uses: lando/transfer-issue-action@1.3.0
id: transfer-issue
with:
pat_token: ${{ secrets.TRANSFER_ISSUE_TOKEN }}
create_stub: false
github_token: ${{ secrets.TRANSFER_ISSUE_TOKEN }}
labels_file_path: '.github/transfer-issue-labels.yml'
map_repo_labels_file_path: '.github/transfer-issue-map-repo-labels.yml'
- name: Update Transferred Issue
Expand Down
7 changes: 3 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ inputs:
destination_repo:
description: 'The destination repo.'
required: false
github_token:
description: 'The GitHub token used to create an authenticated client.'
default: ${{ github.token }}
required: false
pat_token:
description: 'The GitHub Perosnal Access Token.'
required: true
create_stub:
description: 'Create a stub issue with title and description in original repo.'
default: true
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function run() {
destRepo = dest_repo_check;
}

const token = core.getInput('github_token', {required: true});
const token = core.getInput('pat_token', {required: true});
const octokit = getOctokit(token);
const origOwner = payload.repository.owner.login;
const origRepo = payload.repository.name;
Expand Down

0 comments on commit 4f9d54e

Please sign in to comment.