Skip to content

Commit f917f9b

Browse files
authored
feat: Add addional GH token descriptor name (#375)
Signed-off-by: Pascal Zimmermann <pascal.zimmermann@theiotstudio.com>
1 parent fdfe7e8 commit f917f9b

4 files changed

Lines changed: 34 additions & 16 deletions

File tree

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ jobs:
8484
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
8585
git config --local user.name "github-actions[bot]"
8686
git commit -a -m "Add changes"
87+
- name: Push changes
88+
uses: ad-m/github-push-action@master
89+
with:
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
branch: ${{ github.ref }}
92+
```
93+
94+
or
95+
96+
```yaml
8797
- name: Push changes
8898
uses: ad-m/github-push-action@master
8999
with:
@@ -303,20 +313,21 @@ jobs:
303313

304314
### Inputs
305315

306-
| name | value | default | description |
307-
|--------------------|---------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
308-
| github_token | string | `${{ github.token }}` | [GITHUB_TOKEN](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow) <br /> or a repo scoped <br /> [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). |
309-
| ssh | boolean | false | Determines if ssh/ Deploy Keys is used. |
310-
| branch | string | (default) | Destination branch to push changes. <br /> Can be passed in using `${{ github.ref }}`. |
311-
| force | boolean | false | Determines if force push is used. |
312-
| force_with_lease | boolean | false | Determines if force-with-lease push is used. Please specify the corresponding branch inside `ref` section of the checkout action e.g. `ref: ${{ github.head_ref }}`. Be aware, if you want to update the branch and the corresponding tag please use the `force` parameter instead of the `force_with_lease` option. |
313-
| atomic | boolean | true | Determines if atomic push is used. |
314-
| push_to_submodules | string | 'on-demand' | Determines if --recurse-submodules=<strategy> is used. The value defines the used strategy. |
315-
| push_only_tags | boolean | false | Determines if the action should only push the tags, default false |
316-
| tags | boolean | false | Determines if `--tags` is used. |
317-
| directory | string | '.' | Directory to change to before pushing. |
318-
| repository | string | '' | Repository name. <br /> Default or empty repository name represents <br /> current github repository. <br /> If you want to push to other repository, <br /> you should make a [personal access token](https://github.com/settings/tokens) <br /> and use it as the `github_token` input. |
319-
| pull | string | false | Perform a `git pull` before pushing. Accepted values: `rebase` (or `true`) uses `--rebase`, `merge` uses `--no-rebase`, `ff-only` uses `--ff-only`. Leave unset or `false` to skip the pull entirely. **Requires a real branch to be checked out** (detached HEAD state is not supported — the action will abort with an error). |
316+
| name | value | default | description |
317+
|--------------------|---------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
318+
| token | string | '' | Preferred input name. <br /> [GITHUB_TOKEN](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow) or a repo scoped [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). If unset, falls back to `github_token`. |
319+
| github_token | string | `${{ github.token }}` | Non-breaking change config option for the token parameter. |
320+
| ssh | boolean | false | Determines if ssh/ Deploy Keys is used. |
321+
| branch | string | (default) | Destination branch to push changes. <br /> Can be passed in using `${{ github.ref }}`. |
322+
| force | boolean | false | Determines if force push is used. |
323+
| force_with_lease | boolean | false | Determines if force-with-lease push is used. Please specify the corresponding branch inside `ref` section of the checkout action e.g. `ref: ${{ github.head_ref }}`. Be aware, if you want to update the branch and the corresponding tag please use the `force` parameter instead of the `force_with_lease` option. |
324+
| atomic | boolean | true | Determines if atomic push is used. |
325+
| push_to_submodules | string | 'on-demand' | Determines if --recurse-submodules=<strategy> is used. The value defines the used strategy. |
326+
| push_only_tags | boolean | false | Determines if the action should only push the tags, default false |
327+
| tags | boolean | false | Determines if `--tags` is used. |
328+
| directory | string | '.' | Directory to change to before pushing. |
329+
| repository | string | '' | Repository name. <br /> Default or empty repository name represents <br /> current github repository. <br /> If you want to push to other repository, <br /> you should make a [personal access token](https://github.com/settings/tokens) <br /> and use it as the `token` input. |
330+
| pull | string | false | Perform a `git pull` before pushing. Accepted values: `rebase` (or `true`) uses `--rebase`, `merge` uses `--no-rebase`, `ff-only` uses `--ff-only`. Leave unset or `false` to skip the pull entirely. **Requires a real branch to be checked out** (detached HEAD state is not supported — the action will abort with an error). |
320331

321332
## Troubleshooting
322333

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ branding:
55
icon: upload-cloud
66
color: green
77
inputs:
8+
token:
9+
description: 'GitHub token or PAT token'
10+
required: false
811
github_token:
912
description: 'GitHub token or PAT token'
1013
required: false

start.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ const main = async () => {
4949
const headers = {
5050
'User-Agent': 'github.com/ad-m/github-push-action'
5151
};
52-
if (process.env.INPUT_GITHUB_TOKEN) headers.Authorization = `token ${process.env.INPUT_GITHUB_TOKEN}`;
52+
const token = process.env.INPUT_TOKEN || process.env.INPUT_GITHUB_TOKEN;
53+
if (token) headers.Authorization = `token ${token}`;
5354
const body = JSON.parse(await get(`${process.env.GITHUB_API_URL}/repos/${repository}`, { headers }))
5455
branch = body.default_branch;
5556
}
@@ -60,6 +61,7 @@ const main = async () => {
6061
INPUT_REPOSITORY: repository,
6162
INPUT_GITHUB_URL_PROTOCOL: github_url_protocol,
6263
INPUT_GITHUB_URL: github_url,
64+
INPUT_GITHUB_TOKEN: process.env.INPUT_TOKEN || process.env.INPUT_GITHUB_TOKEN,
6365
}
6466
});
6567
};

start.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
1616

1717
echo "Push to branch $INPUT_BRANCH";
1818
[ -z "${INPUT_GITHUB_TOKEN}" ] && {
19-
echo "Missing input 'github_token: ${{ secrets.GITHUB_TOKEN }}'.";
19+
echo "Missing input 'token' (or legacy 'github_token'). Please set one of:";
20+
echo " token: \${{ secrets.GITHUB_TOKEN }}";
21+
echo " github_token: \${{ secrets.GITHUB_TOKEN }}";
2022
exit 1;
2123
};
2224

0 commit comments

Comments
 (0)