Skip to content

Commit 2aa4b0e

Browse files
committed
chore: git config and git clone improved
1 parent ee3b87a commit 2aa4b0e

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

.github/actions/git-clone/action.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ inputs:
2424
outputs:
2525
TOKEN:
2626
description: template file path
27-
value: ${{ steps.get-token.outputs.token || inputs.git-token }}
27+
value: ${{ steps.get-app-token.outputs.token || inputs.git-token }}
28+
USER_EMAIL:
29+
description: Git user email
30+
value: ${{ steps.get-user-info.outputs.USER_EMAIL }} || ${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com
31+
USER_NAME:
32+
description: Git user name
33+
value: ${{ steps.get-user-info.outputs.USER_NAME || github.actor }}
2834

2935
runs:
3036
using: composite
3137
steps:
3238
- name: GH App get Token
33-
id: get-token
39+
id: get-app-token
3440
if: inputs.mode == 'app'
3541
uses: actions/create-github-app-token@v1
3642
with:
@@ -41,7 +47,17 @@ runs:
4147
if: inputs.mode == 'app'
4248
with:
4349
fetch-depth: ${{ inputs.fetch-depth }}
44-
token: ${{ steps.get-token.outputs.token }}
50+
token: ${{ steps.get-app-token.outputs.token }}
51+
- name: Get GitHub App User info
52+
id: get-user-info
53+
if: inputs.mode == 'app'
54+
run: |
55+
echo "USER_ID=$(gh api "/users/${{ steps.get-app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
56+
echo "USER_EMAIL=${USER_ID}+${{ steps.get-app-token.outputs.app-slug }}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
57+
echo "USER_NAME=${{ steps.get-app-token.outputs.app-slug }}[bot]" >> "$GITHUB_OUTPUT"
58+
shell: bash
59+
env:
60+
GH_TOKEN: ${{ steps.get-app-token.outputs.token }}
4561
- name: Clone code (PAT)
4662
id: clone
4763
if: inputs.mode == 'pat'

.github/actions/git-config/action.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ inputs:
1313
description: tls verification
1414
git-email:
1515
required: false
16-
16+
default: ${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com
17+
description: default git email
18+
git-username:
19+
required: false
20+
default: ${{ github.actor }}
1721
description: default git email
1822

1923
runs:
@@ -25,10 +29,10 @@ runs:
2529
echo -e "${CYAN}[ INFO ] > Git version.${BLANK}"
2630
git version
2731
28-
echo -e "${YELLOW}[ EXECUTING ] > setting up git config to mail ${{ inputs.git-email }} and username ${GITHUB_ACTOR}.${BLANK}"
32+
echo -e "${YELLOW}[ EXECUTING ] > setting up git config to mail ${{ inputs.git-email }} and username ${{ inputs.git-username }}.${BLANK}"
2933
git config --global --add safe.directory "$(realpath "${{ inputs.git-workdir }}")"
3034
git config --global user.email "${{ inputs.git-email }}"
31-
git config --global user.name "${GITHUB_ACTOR}"
35+
git config --global user.name "${{ inputs.git-username }}"
3236
git config --global http.sslVerify ${{ inputs.tls-verify }}
3337
git config --list
3438
shell: bash

.github/workflows/__docker-build__.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ on:
101101
required: false
102102
default: false
103103
type: boolean
104+
always-bump:
105+
required: false
106+
default: "true"
107+
type: string
108+
104109
workflow_dispatch:
105110
concurrency:
106111
group: ${{ github.workflow }}-${{ github.ref }}
@@ -190,7 +195,7 @@ jobs:
190195
component: ${{ inputs.component }}
191196
prerelease: ${{ inputs.prerelease }}
192197
build: "true"
193-
always-bump: "true"
198+
always-bump: ${{ inputs.always-bump }}
194199

195200
- name: Build Docker img [Trunk]
196201
uses: docker/build-push-action@v5

.github/workflows/__docker-release__.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ on:
6767
required: false
6868
default: false
6969
type: boolean
70+
always-bump:
71+
required: false
72+
default: "true"
73+
type: string
74+
7075
workflow_dispatch:
7176
concurrency:
7277
group: ${{ github.workflow }}-${{ github.ref }}
@@ -89,11 +94,13 @@ jobs:
8994
private-key: ${{ secrets.gh-app-private-key }}
9095
fetch-depth: 0
9196

92-
# - name: Git config
93-
# id: git-config
94-
# uses: ixxeL-DevOps/gha-templates/.github/actions/git-config@main
95-
# with:
96-
# git-workdir: ${{ inputs.git-workdir }}
97+
- name: Git config
98+
id: git-config
99+
uses: ixxeL-DevOps/gha-templates/.github/actions/git-config@main
100+
with:
101+
git-workdir: ${{ inputs.git-workdir }}
102+
git-email: ${{ steps.clone.outputs.USER_EMAIL }}
103+
git-username: ${{ steps.clone.outputs.USER_NAME }}
97104

98105
- name: Calculate current and next tag
99106
id: svu
@@ -103,6 +110,7 @@ jobs:
103110
component: ${{ inputs.component }}
104111
prerelease: ${{ inputs.prerelease }}
105112
build: "false"
113+
always-bump: ${{ inputs.always-bump }}
106114

107115
- name: Get last tag (Release Candidate)
108116
id: get-last-tag-rc

0 commit comments

Comments
 (0)