Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
log-in

GitHub Action

Configure git credentials

v2.1.1

Configure git credentials

log-in

Configure git credentials

Set git credentials for commits and operations with remotes

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Configure git credentials

uses: OleksiyRudenko/[email protected]

Learn more about this action in OleksiyRudenko/gha-git-credentials

Choose a version

Git Credentials

GitHub Action for setting up git credentials.

This action can be useful when workflow provides for creating commits (e.g. when publishing content) and/or pushing commits to remote repos. Action on the marketplace.

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.

This project deployment workflow uses very this action to build its own distribution package.

Table of Contents

Inputs

property name value type default value description
global boolean false global git config used to assign git user name, email and password when true
name string GitHub Action value for git config user.name
email string [email protected] value for git config user.email
actor string github.actor value used to construct GIT_USER
token string n/a required value for git user.password and GIT_USER

The minimally required action configuration requires a token being explicitly specified. Example below uses secrets.GITHUB_TOKEN available to the workflow as a token source.

- uses: oleksiyrudenko/gha-git-credentials@v2-latest
  with:
    token: '${{ secrets.GITHUB_TOKEN }}'

Outputs

No outputs produced.

Usage Example

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@v2-latest
      with:
        token: '${{ secrets.GITHUB_TOKEN }}'
    - run: |
        yarn run build
        yarn run deploy
    # Publish to a branch in a different repo
    # using a PAT generated on that other repo.
    # Option `global` is set to true as the deployment script may create 
    # a temporary local repo for a build and we want it to reuse git user settings.
    # Option `actor` is assigned as per that different repo cloud user.
    - uses: oleksiyrudenko/[email protected]
      with:
        global: true
        name: 'Oleksiy Rudenko'
        email: '[email protected]'
        actor: 'OleksiyRudenko'
        token: '${{ secrets.GL_PAT_WEB_CENTRAL }}'
    - run: |
        git remote add web-central https://gitlab.com/some-organization/website.git
        yarn run deploy web-central/master

You may want to set the global option true when committing to multiple local repositories during the workflow run is anticipated.

Note that the second use of gha-git-credentials refers to a specific version of the action (@v2.1.1). In fact @v2-latest would work here quite fine and is a better approach.

Check What version to use? to choose proper action version reference.

Versions

What version to use?

In workflow .yml file you are required to specify action version. E.g. uses: oleksiyrudenko/gha-git-credentials@v2. @v2 here refers to a very specific version of the action script.

So, in this action the options are:

  • vX, vX.Y, vX.Y.Z - specific version
  • vX-latest - latest release within the major version (no breaking changes, backward compatibility)
  • latest - latest release, major version change may occur
  • <branch-name> - version as per given branch name, useful for testing

Whenever non-breaking changes introduced, having backward compatibility secured, a patch version is released and the relevant vX-latest tag is moved to point at the latest release within current major version.

Using vX-latest is a recommended choice.

Below are key features of the releases. Check CHANGELOG for details.

v2.1.1

Configure action to use NodeJS v16 instead of v12. Reason.

v2.1.0

Introduce global option to configure global git user name, email and password. Default is false for backward compatibility.

v2

Changed the way GIT_USER env var is being assigned.

Reason: GitHub deprecated add-path and set-env commands.

v1

Features:

  • Configurable git user name, email and password for commits created in a course of the workflow
  • Configurable actor and token (GIT_USER) to push updates from a workflow

Action Users

As of July 25, 2022, 685 projects on GitHub depend on this GitHub action.

15 top rated

url stars
https://github.com/yewstack/yew 23K
https://github.com/lingui/js-lingui 3.4K
https://github.com/ibis-project/ibis 1.9K
https://github.com/wickedest/Mergely 1.0K
https://github.com/CuyZ/Valinor 584
https://github.com/snowplow/snowplow-javascript-tracker 487
https://github.com/themoonisacheese/2bored2wait 341
https://github.com/Lightning-AI/tutorials 152
https://github.com/diegoazh/gmap-vue 133
https://github.com/cookiejar/cookietemple 123
https://github.com/jessedobbelaere/tailwindcss-sketch-kit 117
https://github.com/zeromq/pyre 113
https://github.com/splunk/splunk-connect-for-syslog 100
https://github.com/QuiltServerTools/Ledger 96
https://github.com/JustLiquidity/DEFAULT-TOKEN-LIST 85

Stats built with ghtopdep

License

Scripts and documentation in this project are released under the MIT license.

No affiliation with GitHub Inc.

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.