-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
134 lines (124 loc) · 4.35 KB
/
action.yaml
File metadata and controls
134 lines (124 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: 'GoLangCI Lint Action'
description: 'A GitHub Action to run GoLangCI-Lint on pull requests with private module support'
inputs:
lerian_studio_midaz_push_bot_app_id:
description: 'The App ID for the GitHub App'
required: true
lerian_studio_midaz_push_bot_private_key:
description: 'The private key for the GitHub App'
required: true
lerian_ci_cd_user_gpg_key:
description: 'The GPG key for the user'
required: true
lerian_ci_cd_user_gpg_key_password:
description: 'The password for the GPG key'
required: true
lerian_ci_cd_user_name:
description: 'The name of the user'
required: true
lerian_ci_cd_user_email:
description: 'The email of the user'
required: true
go_version:
description: 'The Go version to use'
required: true
default: '1.23'
github_token:
description: 'GitHub token for API interactions'
required: true
reviewdog_level:
description: 'Level of reviewdog output'
required: true
default: 'error'
fail_level:
description: 'Fail level for reviewdog'
required: true
default: 'any'
reporter:
description: 'Reviewdog reporter type'
required: true
default: 'github-pr-review'
filter_mode:
description: 'Reviewdog filter mode'
required: true
default: 'diff_context'
golangci_lint_version:
description: 'GolangCI-Lint version to use'
required: true
default: 'v1.64.8'
cache:
description: 'Enable GolangCI-Lint caching (true/false)'
required: false
default: 'false'
manage_token:
description: 'Personal access token to access private Go modules'
required: false
runs:
using: 'composite'
steps:
- name: Create GitHub App Token
if: github.event.pull_request.head.repo.fork == false
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ inputs.lerian_studio_midaz_push_bot_app_id }}
private-key: ${{ inputs.lerian_studio_midaz_push_bot_private_key }}
- name: Import GPG Key
if: github.event.pull_request.head.repo.fork == false
uses: crazy-max/ghaction-import-gpg@v6
id: import_gpg
with:
gpg_private_key: ${{ inputs.lerian_ci_cd_user_gpg_key }}
passphrase: ${{ inputs.lerian_ci_cd_user_gpg_key_password }}
git_committer_name: ${{ inputs.lerian_ci_cd_user_name }}
git_committer_email: ${{ inputs.lerian_ci_cd_user_email }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go_version }}
cache: false
- name: Configure GOPRIVATE and .netrc for private modules
shell: bash
run: |
echo "GOPRIVATE=github.com/LerianStudio/*" >> $GITHUB_ENV
echo "GONOSUMDB=github.com/LerianStudio/*" >> $GITHUB_ENV
if [ -n "${{ inputs.manage_token }}" ]; then
echo -e "machine github.com\nlogin oauth2\npassword ${{ inputs.manage_token }}" > ~/.netrc
chmod 600 ~/.netrc
fi
- name: Download Go Modules
shell: bash
run: go mod download
- name: Run GoLangCI-Lint for Non-Fork Repos
if: github.event.pull_request.head.repo.fork == false
uses: reviewdog/action-golangci-lint@v2
with:
go_version: ${{ inputs.go_version }}
tool_name: golint
level: ${{ inputs.reviewdog_level }}
fail_level: ${{ inputs.fail_level }}
reporter: ${{ inputs.reporter }}
filter_mode: ${{ inputs.filter_mode }}
golangci_lint_version: ${{ inputs.golangci_lint_version }}
reviewdog_github_api_token: ${{ steps.app-token.outputs.token }}
git_author_name: ${{ inputs.lerian_ci_cd_user_name }}
git_author_email: ${{ inputs.lerian_ci_cd_user_email }}
git_committer_name: ${{ inputs.lerian_ci_cd_user_name }}
git_committer_email: ${{ inputs.lerian_ci_cd_user_email }}
cache: ${{ inputs.cache }}
- name: Setup Go for Forked Repo
if: github.event.pull_request.head.repo.fork == true
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: Run GoLangCI-Lint for Forked Repos
if: github.event.pull_request.head.repo.fork == true
uses: golangci/golangci-lint-action@v4
with:
version: latest