-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (78 loc) · 2.74 KB
/
update-all-lint-rules.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: Update all lint rules
on:
schedule:
- cron: '0 0 * * 3'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
branch: "update-all-lint-rules-${{ github.run_number }}"
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
has_diff: ${{ steps.check_diff.outputs.has_diff }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
- name: Run Diffscrape
working-directory: ./packages/diffscrape
run: |
dart run diffscrape \
--uri "https://dart.dev/tools/linter-rules/all" \
--file "../altive_lints/lib/all_lint_rules.yaml" \
--query-selector "pre code" \
--verbose
- name: Check for changes
id: check_diff
run: |
diff_count=$(git diff --name-only --relative=packages/altive_lints/lib | wc -l)
echo "diff_count=$diff_count" >> "$GITHUB_ENV"
if [ "$diff_count" -ne "0" ]; then
echo "has_diff=true" >> "$GITHUB_OUTPUT"
else
echo "has_diff=false" >> "$GITHUB_OUTPUT"
fi
- name: Create branch, configure git, commit & push
if: env.diff_count != '0'
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git switch -c ${{ env.branch }}
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: update
if: needs.update.outputs.has_diff == 'true'
steps:
- uses: actions/checkout@v4
- name: Generate GitHub 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 \
--base "$GITHUB_REF" \
--head ${{ env.branch }} \
--title "feat: Update all lint rules" \
--body "Automated pull request to update lint rules." \
--assignee "$GITHUB_ACTOR"
- 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}"