-
Notifications
You must be signed in to change notification settings - Fork 87
84 lines (74 loc) · 2.35 KB
/
tidy-autocommit.yml
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
name: Autocommit `go mod tidy`
on:
workflow_call:
secrets:
APP_ID:
required: true
APP_PRIVATE_KEY:
required: true
inputs:
repository:
type: string
required: true
ref:
type: string
required: true
jobs:
autocommit-tidy:
runs-on: ubuntu-latest
steps:
- name: Generate token
uses: tibdex/github-app-token@v2
id: generate-token
env:
# Use default OpenSSL config.
#
# See https://github.com/tibdex/github-app-token/issues/54.
OPENSSL_CONF: /dev/null
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
token: ${{ steps.generate-token.outputs.token }}
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "oldstable"
cache: false
- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
# Notice: we're using read-only cache.
#
# See https://github.com/actions/setup-go/issues/357#issuecomment-1486486358
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-go-
- name: Tidy go.mod files
run: make tidy_all
# See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/managing-pull-requests-for-dependency-updates#allowing-dependabot-to-rebase-and-force-push-over-extra-commits
# that is why we add `[dependabot skip]` to commit.
- name: Commit and push
run: |
git add go.mod go.sum
git add examples/go.mod examples/go.sum
git \
-c user.name="GitHub" \
-c user.email="[email protected]" \
commit \
-m "chore: go mod tidy" \
-m "[dependabot skip]" \
--author="GitHub"
git push origin