GitHub Action
Configure git credentials
GitHub Action for setting up git credentials.
This project deployment workflow uses this action.
This can be useful when workflow provides for creating commits (e.g. when publishing content) and/or pushing commits to remote repos.
Default values would work for the most cases. However token parameter must be passed to the action explicitly.
GitHub requires the use of a Personal Access Token assigned to the calling workflow secrets for pushing to repositories other than the repo the workflow is triggered for.
Pushing to the current repository should work
with the always-available GitHub Token {{ secrets.GITHUB_TOKEN }}
.
You may also want to override default git user name and email.
Actor would also be overridden when pushing to a repo cloud other than GitHub.
name
: value for git config user.name (default:GitHub Action
)email
: value for git config user.email (default:[email protected]
)actor
: value used to construct GIT_USER (default: github.actor)token
: value for git config user.password and GIT_USER
No outputs produced.
name: Deployment
on:
push:
branches:
- master
jobs:
publish:
- uses: actions/checkout@v2
# publish to a branch in current repo using GITHUB_TOKEN and other default settings
- uses: oleksiyrudenko/gha-git-credentials@v1
with:
token: '${{ secrets.GITHUB_TOKEN }}'
- run: |
yarn run build
yarn run deploy
# publish to a branch in different repo using a PAT generated on that other repo
- uses: oleksiyrudenko/gha-git-credentials@v2
with:
name: 'Oleksiy Rudenko'
email: '[email protected]'
actor: 'OleksiyRudenko'
token: '${{ secrets.GH_PAT_WEB_CENTRAL }}'
- run: |
git remote add web-central https://github.com/some-organization/website.git
yarn run deploy web-central/master
Check CHANGELOG for details.
Changed the way GIT_USER
env var is being assigned.
Reason:
GitHub deprecated add-path
and set-env
commands.
Features:
- Configurable user name and user email for commits created by a custom action
- Configurable actor and token (GIT_USER) to push updates from a custom action
Scripts and documentation in this project are released under the MIT license.
GitHub are registered trademarks of GitHub, Inc. GitHub name used in this project are for identification purposes only. The project is not associated in any way with GitHub Inc. and is not an official solution of GitHub Inc. It was made available in order to facilitate the use of the site GitHub.