parent
dda7a419b6
commit
e69c0c047e
18
.github/workflows/build.yml
vendored
18
.github/workflows/build.yml
vendored
@ -7,14 +7,14 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
- name: Verify action syntax
|
- name: Verify action syntax
|
||||||
# The action should not publish any real changes, but should succeed.
|
# The action should not publish any real changes, but should succeed.
|
||||||
uses: './'
|
uses: './'
|
||||||
with:
|
with:
|
||||||
github_token: '${{ secrets.GITHUB_TOKEN }}'
|
github_token: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
branch: '${{ github.ref }}'
|
branch: '${{ github.ref }}'
|
26
README.md
26
README.md
@ -39,6 +39,32 @@ jobs:
|
|||||||
branch: ${{ github.ref }}
|
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
|
### Inputs
|
||||||
|
|
||||||
| name | value | default | description |
|
| name | value | default | description |
|
||||||
|
@ -13,6 +13,9 @@ inputs:
|
|||||||
description: 'GitHub url or GitHub Enterprise url'
|
description: 'GitHub url or GitHub Enterprise url'
|
||||||
required: true
|
required: true
|
||||||
default: ${{ github.server_url }}
|
default: ${{ github.server_url }}
|
||||||
|
ssh:
|
||||||
|
description: 'Specify if ssh should be used'
|
||||||
|
required: false
|
||||||
repository:
|
repository:
|
||||||
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
|
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
|
||||||
default: ''
|
default: ''
|
||||||
|
12
start.sh
12
start.sh
@ -2,6 +2,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
INPUT_FORCE=${INPUT_FORCE:-false}
|
INPUT_FORCE=${INPUT_FORCE:-false}
|
||||||
|
INPUT_SSH=${INPUT_SSH:-false}
|
||||||
INPUT_TAGS=${INPUT_TAGS:-false}
|
INPUT_TAGS=${INPUT_TAGS:-false}
|
||||||
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
|
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
|
||||||
_FORCE_OPTION=''
|
_FORCE_OPTION=''
|
||||||
@ -13,17 +14,18 @@ echo "Push to branch $INPUT_BRANCH";
|
|||||||
exit 1;
|
exit 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ${INPUT_FORCE}; then
|
|
||||||
_FORCE_OPTION='--force'
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ${INPUT_TAGS}; then
|
if ${INPUT_TAGS}; then
|
||||||
_TAGS='--tags'
|
_TAGS='--tags'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ${INPUT_DIRECTORY}
|
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 config --local --add safe.directory ${INPUT_DIRECTORY}
|
git config --local --add safe.directory ${INPUT_DIRECTORY}
|
||||||
|
|
||||||
git push "${remote_repo}" HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION $_TAGS;
|
git push "${remote_repo}" HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION $_TAGS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user