Skip to content

Commit

Permalink
fix(credentials): simplify git credentials action
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Jan 16, 2023
1 parent 5e31d0b commit e466936
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 60 deletions.
32 changes: 13 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,12 @@ Generate credentials and git committer details for a [GitHub app].

##### Outputs

| Name | Description | Example |
|-----------------------|------------------------------------------|----------------------------------------|
| `name` | The name of the app. | `my-app` |
| `token` | The GitHub token of the app. | `ghp_1234567890` |
| `git-author-name` | The name to use as GIT_AUTHOR_NAME. | `my-app[bot]` |
| `git-author-email` | The email to use as GIT_AUTHOR_EMAIL. | `my-app[bot]@users.noreply.github.com` |
| `git-committer-name` | The name to use as GIT_COMMITTER_NAME. | `my-app[bot]` |
| `git-committer-email` | The email to use as GIT_COMMITTER_EMAIL. | `my-app[bot]@users.noreply.github.com` |
| Name | Description | Example |
|-------------|------------------------------|----------------------------------------|
| `name` | The name of the app. | `my-app` |
| `token` | The GitHub token of the app. | `ghp_1234567890` |
| `git-name` | The name to use with git. | `my-app[bot]` |
| `git-email` | The email to use with git. | `my-app[bot]@users.noreply.github.com` |

See also [setup-git-credentials] for setting up git using a [GitHub app].

Expand Down Expand Up @@ -397,9 +395,6 @@ installed if using any non-built-in [semantic-release] plugins.

Set up git credentials and authenticate as a [GitHub app].

1. Runs [oleksiyrudenko/gha-git-credentials@v2.1]
- Needs a [GitHub] app id in `app-id` and a private key in `private-key`.

##### Example

```yaml
Expand All @@ -418,14 +413,13 @@ Set up git credentials and authenticate as a [GitHub app].

##### Outputs

| Name | Description | Example |
|-----------------------|------------------------------------------|----------------------------------------|
| `name` | The name of the app. | `my-app` |
| `token` | The GitHub token of the app. | `ghp_1234567890` |
| `git-author-name` | The name to use as GIT_AUTHOR_NAME. | `my-app[bot]` |
| `git-author-email` | The email to use as GIT_AUTHOR_EMAIL. | `my-app[bot]@users.noreply.github.com` |
| `git-committer-name` | The name to use as GIT_COMMITTER_NAME. | `my-app[bot]` |
| `git-committer-email` | The email to use as GIT_COMMITTER_EMAIL. | `my-app[bot]@users.noreply.github.com` |
| Name | Description | Example |
|-------------|------------------------------|----------------------------------------|
| `name` | The name of the app. | `my-app` |
| `token` | The GitHub token of the app. | `ghp_1234567890` |
| `git-name` | The name to use with git. | `my-app[bot]` |
| `git-email` | The email to use with git. | `my-app[bot]@users.noreply.github.com` |


#### rebase

Expand Down
26 changes: 8 additions & 18 deletions setup-app-credentials/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,13 @@ outputs:
description: 'The GitHub token of the app.'
value: ${{ steps.create-outputs.outputs.token }}

git-author-name:
description: 'The name to use as GIT_AUTHOR_NAME.'
value: ${{ steps.create-outputs.outputs.git-author-name }}
git-name:
description: 'The name to use with git.'
value: ${{ steps.create-outputs.outputs.git-name }}

git-author-email:
description: 'The email to use as GIT_AUTHOR_EMAIL.'
value: ${{ steps.create-outputs.outputs.git-author-email }}

git-committer-name:
description: 'The name to use as GIT_COMMITTER_NAME.'
value: ${{ steps.create-outputs.outputs.git-committer-name }}

git-committer-email:
description: 'The email to use as GIT_COMMITTER_EMAIL.'
value: ${{ steps.create-outputs.outputs.git-committer-email }}
git-email:
description: 'The email to use with git.'
value: ${{ steps.create-outputs.outputs.git-email }}

runs:
using: composite
Expand All @@ -54,7 +46,5 @@ runs:
echo "name=${bot_name}" >> $GITHUB_OUTPUT
echo "token=${{ steps.generate-token.outputs.BOT_TOKEN }}" >> $GITHUB_OUTPUT
echo "git-author-name=${bot_git_name}" >> $GITHUB_OUTPUT
echo "git-author-email=${bot_git_email}" >> $GITHUB_OUTPUT
echo "git-committer-name=${bot_git_name}" >> $GITHUB_OUTPUT
echo "git-committer-email=${bot_git_email}" >> $GITHUB_OUTPUT
echo "git-name=${bot_git_name}" >> $GITHUB_OUTPUT
echo "git-email=${bot_git_email}" >> $GITHUB_OUTPUT
44 changes: 21 additions & 23 deletions setup-git-credentials/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,38 @@ inputs:
outputs:
name:
description: 'The name of the app.'
value: ${{ steps.create-outputs.outputs.name }}
value: ${{ steps.credentials.outputs.name }}

token:
description: 'The GitHub token of the app.'
value: ${{ steps.create-outputs.outputs.token }}
value: ${{ steps.credentials.outputs.token }}

git-author-name:
description: 'The name to use as GIT_AUTHOR_NAME.'
value: ${{ steps.create-outputs.outputs.git-author-name }}
git-name:
description: 'The name to use with git.'
value: ${{ steps.credentials.outputs.git-name }}

git-author-email:
description: 'The email to use as GIT_AUTHOR_EMAIL.'
value: ${{ steps.create-outputs.outputs.git-author-email }}

git-committer-name:
description: 'The name to use as GIT_COMMITTER_NAME.'
value: ${{ steps.create-outputs.outputs.git-committer-name }}

git-committer-email:
description: 'The email to use as GIT_COMMITTER_EMAIL.'
value: ${{ steps.create-outputs.outputs.git-committer-email }}
git-email:
description: 'The email to use with git.'
value: ${{ steps.credentials.outputs.git-email }}

runs:
using: composite
steps:
- uses: myparcelnl/actions/setup-app-credentials@v3
id: create-outputs
id: credentials
with:
app-id: ${{ inputs.app-id }}
private-key: ${{ inputs.private-key }}

- uses: oleksiyrudenko/gha-git-credentials@v2.1
with:
token: ${{ steps.create-outputs.outputs.token }}
name: ${{ steps.create-outputs.outputs.git-author-name }}
email: ${{ steps.create-outputs.outputs.git-author-email }}
actor: ${{ steps.create-outputs.outputs.git-author-name }}
- name: 'Set git credentials'
shell: bash
run: |
git_name=${{ steps.credentials.outputs.git-name }}
git_email=${{ steps.credentials.outputs.git-email }}
git_token=${{ steps.credentials.outputs.token }}
git config --global user.name "${git_name}"
git config --global user.email "${git_email}"
git config --global user.password "${git_token}"
echo "GIT_USER=${git_name}:${git_token}" >> $GITHUB_ENV

0 comments on commit e466936

Please sign in to comment.