Merge branch 'master' into patch-4
This commit is contained in:
commit
7e6f17c52d
39
README.md
39
README.md
@ -39,6 +39,27 @@ jobs:
|
|||||||
branch: ${{ github.ref }}
|
branch: ${{ github.ref }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
An example workflow to use the force-with-lease parameter to force push to a repository:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Commit files
|
||||||
|
run: |
|
||||||
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --local user.name "github-actions[bot]"
|
||||||
|
git commit -m "Add changes" -a
|
||||||
|
- name: Push changes
|
||||||
|
uses: ad-m/github-push-action@master
|
||||||
|
with:
|
||||||
|
force_with_lease: true
|
||||||
|
```
|
||||||
An example workflow to authenticate with GitHub Platform via Deploy Keys or in general SSH:
|
An example workflow to authenticate with GitHub Platform via Deploy Keys or in general SSH:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -67,14 +88,16 @@ jobs:
|
|||||||
|
|
||||||
### Inputs
|
### Inputs
|
||||||
|
|
||||||
| name | value | default | description |
|
| name | value | default | description |
|
||||||
| ---- | ----- | ------- | ----------- |
|
|------------------| ----- | ------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| 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). |
|
| 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). |
|
||||||
| branch | string | (default) | Destination branch to push changes. <br /> Can be passed in using `${{ github.ref }}`. |
|
| ssh | boolean | false | Determines if ssh/ Deploy Keys is used. |
|
||||||
| force | boolean | false | Determines if force push is used. |
|
| branch | string | (default) | Destination branch to push changes. <br /> Can be passed in using `${{ github.ref }}`. |
|
||||||
| tags | boolean | false | Determines if `--tags` is used. |
|
| force | boolean | false | Determines if force push is used. |
|
||||||
| directory | string | '.' | Directory to change to before pushing. |
|
| 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 }}`. |
|
||||||
| 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. |
|
| tags | boolean | false | Determines if `--tags` is used. |
|
||||||
|
| directory | string | '.' | Directory to change to before pushing. |
|
||||||
|
| 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. |
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ branding:
|
|||||||
inputs:
|
inputs:
|
||||||
github_token:
|
github_token:
|
||||||
description: 'GitHub token or PAT token'
|
description: 'GitHub token or PAT token'
|
||||||
required: true
|
required: false
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
github_url:
|
github_url:
|
||||||
description: 'GitHub url or GitHub Enterprise url'
|
description: 'GitHub url or GitHub Enterprise url'
|
||||||
required: true
|
required: false
|
||||||
default: ${{ github.server_url }}
|
default: ${{ github.server_url }}
|
||||||
ssh:
|
ssh:
|
||||||
description: 'Specify if ssh should be used'
|
description: 'Specify if ssh should be used'
|
||||||
@ -26,6 +26,9 @@ inputs:
|
|||||||
force:
|
force:
|
||||||
description: 'Determines if force push is used'
|
description: 'Determines if force push is used'
|
||||||
required: false
|
required: false
|
||||||
|
force_with_lease:
|
||||||
|
description: 'Determines if force-with-lease push is used'
|
||||||
|
required: false
|
||||||
tags:
|
tags:
|
||||||
description: 'Determines if --tags is used'
|
description: 'Determines if --tags is used'
|
||||||
required: false
|
required: false
|
||||||
|
20
start.sh
20
start.sh
@ -2,6 +2,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
INPUT_FORCE=${INPUT_FORCE:-false}
|
INPUT_FORCE=${INPUT_FORCE:-false}
|
||||||
|
INPUT_FORCE_WITH_LEASE=${INPUT_FORCE_WITH_LEASE:-false}
|
||||||
INPUT_SSH=${INPUT_SSH:-false}
|
INPUT_SSH=${INPUT_SSH:-false}
|
||||||
INPUT_TAGS=${INPUT_TAGS:-false}
|
INPUT_TAGS=${INPUT_TAGS:-false}
|
||||||
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
|
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
|
||||||
@ -14,9 +15,18 @@ echo "Push to branch $INPUT_BRANCH";
|
|||||||
exit 1;
|
exit 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ${INPUT_FORCE} && ${INPUT_FORCE_WITH_LEASE}; then
|
||||||
|
echo 'Please, specify only force or force_with_lease and not both.';
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
if ${INPUT_FORCE}; then
|
if ${INPUT_FORCE}; then
|
||||||
_FORCE_OPTION='--force'
|
_FORCE_OPTION='--force'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ${INPUT_FORCE_WITH_LEASE}; then
|
||||||
|
_FORCE_OPTION='--force-with-lease'
|
||||||
|
fi
|
||||||
|
|
||||||
if ${INPUT_TAGS}; then
|
if ${INPUT_TAGS}; then
|
||||||
_TAGS='--tags'
|
_TAGS='--tags'
|
||||||
@ -30,4 +40,8 @@ else
|
|||||||
remote_repo="${INPUT_GITHUB_URL_PROTOCOL}//${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@${INPUT_GITHUB_URL}/${REPOSITORY}.git"
|
remote_repo="${INPUT_GITHUB_URL_PROTOCOL}//${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@${INPUT_GITHUB_URL}/${REPOSITORY}.git"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git push "${remote_repo}" HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION $_TAGS;
|
if ${INPUT_FORCE_WITH_LEASE}; then
|
||||||
|
git push --follow-tags $_FORCE_OPTION $_TAGS;
|
||||||
|
else
|
||||||
|
git push "${remote_repo}" HEAD:${INPUT_BRANCH} --verbose --follow-tags $_FORCE_OPTION $_TAGS;
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user