Merge branch 'master' into patch-4

This commit is contained in:
Tonye Jack
2022-06-16 00:14:47 -04:00
committed by GitHub
4 changed files with 46 additions and 12 deletions

View File

@ -7,14 +7,14 @@ on:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Verify action syntax
# The action should not publish any real changes, but should succeed.
uses: './'
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
branch: '${{ github.ref }}'
- uses: actions/checkout@master
- name: Verify action syntax
# The action should not publish any real changes, but should succeed.
uses: './'
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
branch: '${{ github.ref }}'

View File

@ -39,6 +39,32 @@ jobs:
branch: ${{ github.ref }}
```
An example workflow to authenticate with GitHub Platform via Deploy Keys or in general SSH:
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
persist-credentials: true
- name: Create local changes
run: |
...
- name: Commit files
run: |
git config --local user.email "41898282+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:
ssh: true
branch: ${{ github.ref }}
```
### Inputs
| name | value | default | description |

View File

@ -13,6 +13,9 @@ inputs:
description: 'GitHub url or GitHub Enterprise url'
required: true
default: ${{ github.server_url }}
ssh:
description: 'Specify if ssh should be used'
required: false
repository:
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
default: ''

View File

@ -2,6 +2,7 @@
set -e
INPUT_FORCE=${INPUT_FORCE:-false}
INPUT_SSH=${INPUT_SSH:-false}
INPUT_TAGS=${INPUT_TAGS:-false}
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
_FORCE_OPTION=''
@ -14,8 +15,8 @@ echo "Push to branch $INPUT_BRANCH";
};
if ${INPUT_FORCE}; then
_FORCE_OPTION='--force'
fi
_FORCE_OPTION='--force'
fi
if ${INPUT_TAGS}; then
_TAGS='--tags'
@ -23,6 +24,10 @@ fi
cd ${INPUT_DIRECTORY}
remote_repo="${INPUT_GITHUB_URL_PROTOCOL}//${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@${INPUT_GITHUB_URL}/${REPOSITORY}.git"
if ${INPUT_SSH}; then
remote_repo="git@${INPUT_GITHUB_URL}:${REPOSITORY}.git"
else
remote_repo="${INPUT_GITHUB_URL_PROTOCOL}//${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@${INPUT_GITHUB_URL}/${REPOSITORY}.git"
fi
git push "${remote_repo}" HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION $_TAGS;