-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (76 loc) · 2.51 KB
/
check-all-lint-rule-diffs.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
80
81
82
83
name: Check all lint rule diffs
on:
workflow_dispatch:
schedule:
- cron: '0 0 15 * *'
env:
branch: "update-all-lint-rules"
jobs:
diff:
name: Check diff
runs-on: ubuntu-latest
outputs:
has-diff: ${{ steps.output.outputs.has-diff }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: './diffscrape/go.mod'
cache-dependency-path: './diffscrape/go.sum'
- name: Run go
working-directory: ./diffscrape
run: go run cmd/rules/main.go
- uses: technote-space/get-diff-action@v6
with:
FILES: |
all_lint_rules.yaml
- name: Output diff
id: output
run: echo "has-diff=${{ env.GIT_DIFF }}" >> "$GITHUB_OUTPUT"
commit:
name: Commit diff
runs-on: ubuntu-latest
needs: [diff]
if: ${{ needs.diff.outputs.has-diff }}
steps:
- uses: actions/checkout@v4
- name: Create branch
run: |
git switch -c ${{ env.branch }}
git push origin ${{ env.branch }}
- name: Git config
run: |
git remote set-url origin https://github-actions:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Commit & Push
run: |
git add .
git commit -m "feat: update all_lint_rules"
git push origin ${{ env.branch }}
pull-request:
name: Create Pull-Request
runs-on: ubuntu-latest
needs: [commit]
steps:
- uses: actions/checkout@v4
- name: Generate GiHub App token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.PR_WRITER_APP_ID }}
private_key: ${{ secrets.PR_WRITER_PRIVATE_KEY }}
- name: Create PR
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: gh pr create -B $GITHUB_REF -t ${{ env.branch }} -b "" -a $GITHUB_ACTOR -H ${{ env.branch }}
- name: Revoke GitHub Apps token
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
curl --location --silent --request DELETE \
--url "${GITHUB_API_URL}/installation/token" \
--header "Accept: application/vnd.github+json" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--header "Authorization: Bearer ${GITHUB_TOKEN}"