-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(action): git auth global action
- Loading branch information
1 parent
64c4149
commit ef844bb
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Git: git-auth-global | ||
|
||
## Behavior | ||
|
||
Modify git global config: | ||
- authenticate requests to github.com with Github token | ||
|
||
Global config is cleared in post run | ||
|
||
_useful to use private pre-commit sources in CI_ | ||
|
||
## Usage | ||
|
||
```yaml | ||
jobs: | ||
advanceTag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: "actions/checkout@v3" | ||
|
||
- name: "Git Auth Global" | ||
uses: "meero-com/github-actions-shared-workflows/actions/git/git-auth-global@main" | ||
with: | ||
github-token: ${{ secrets.API_TOKEN_GITHUB }} | ||
``` | ||
Beware of using a `@ref` (`@main` in the example above) which suits your stability requirements in your workflow: | ||
|
||
* Use `@main` if you always want to use the latest version of the workflow. | ||
* Use `@<tag>` if you wan to use a specific frozen version of the workflow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: "Github auth GIT global" | ||
description: "github token auth in global git config" | ||
|
||
inputs: | ||
github-token: | ||
description: The GitHub token used to create an authenticated client | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: git credentials path | ||
id: git-credentials | ||
run: | | ||
store_path=$(pwd)/.git-credentials | ||
echo "path=$store_path" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Global Git auth | ||
uses: gacts/run-and-post-run@v1 | ||
env: | ||
credential_path: ${{ steps.git-credentials.outputs.path }} | ||
with: | ||
run: | | ||
git config --global credential.helper "store --file=$credential_path" | ||
echo "https://${{ inputs.github-token }}:@github.com" > $credential_path | ||
post: | | ||
git config --global --unset credential.helper | ||
rm $credential_path |