forked from rancher-sandbox/rancher-desktop
-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (78 loc) · 2.52 KB
/
go-work-sync.yaml
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
# Sync go.work on PRs
# If not running upstream (where it uses the vault action), requires the
# RUN_WORKFLOW_FROM_WORKFLOW secret to be set.
name: Sync go.work
on:
pull_request_target:
types: [ opened, reopened, synchronize ]
paths:
- '**/go.mod'
- '**/go.sum'
- 'go.work'
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
update-sum:
# We only run this for pull requests from the same repository. This is
# important for security reasons, as we use pull_request_target.
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
id-token: write # Required for ./.github/actions/get-token
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.base_ref }}
- id: get-token
uses: ./.github/actions/get-token
with:
token-secret: ${{ secrets.RUN_WORKFLOW_FROM_WORKFLOW }}
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: true
ref: ${{ github.head_ref }}
fetch-depth: 3
token: ${{ steps.get-token.outputs.token }}
- uses: ./.github/actions/yarn-install
- name: Determine go.mod files
id: go-files
run: >-
printf "go-files=%s go.work\n"
"$(git ls-files '**/go.mod' '**/go.sum' | tr '\r\n' ' ')"
>> "$GITHUB_OUTPUT"
- run: yarn lint:go:fix
- name: Check for changes
id: changed
run: |
if [ -n "$(git status --porcelain -- $GO_FILES)" ]; then
echo changed=true >> "$GITHUB_OUTPUT"
else
echo changed= >> "$GITHUB_OUTPUT"
fi
env:
GO_FILES: ${{ steps.go-files.outputs.go-files }}
- name: Commit changes
if: steps.changed.outputs.changed
run: >-
git
-c user.name="$GIT_AUTHOR_NAME"
-c user.email="$GIT_AUTHOR_EMAIL"
commit
--message='Update go modules'
--message="Signed-off-by: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
--
$GO_FILES
env:
GIT_AUTHOR_NAME: Rancher Desktop Dependency Manager
GIT_AUTHOR_EMAIL: donotuse@rancherdesktop.io
GO_FILES: ${{ steps.go-files.outputs.go-files }}
- name: Push changes
if: steps.changed.outputs.changed
run: |
git show
git push origin ${{ github.head_ref }}