-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (90 loc) · 2.94 KB
/
eslint-auto-update.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
85
86
87
88
89
90
91
92
name: ESLint Fix
on: pull_request
permissions:
contents: write
pull-requests: write
jobs:
# Has dependabot created this PR?
dependabot-metadata:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
outputs:
dependency-group: ${{ steps.metadata.outputs.dependency-group }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# Is this PR an eslint upgrade?
lint-test:
runs-on: ubuntu-latest
needs: dependabot-metadata
if: ${{ needs.dependabot-metadata.outputs.dependency-group == 'eslint' }}
outputs:
outcome: ${{ steps.lint-test.outcome }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install
run: npm ci
- name: Lint test
id: lint-test
run: npm run lint
# Has the eslint upgrade resulted in lint errors? If so, create a PR to attempt a lint --fix, in case they can be automatically resolved
create-pr:
runs-on: ubuntu-latest
needs: lint-test
if: ${{ always() && needs.lint-test.outputs.outcome == 'failure' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install
run: npm ci
- name: Lint Fix
run: npm run lint-fix
- name: git reset to include the version bumps in the PR
run: git reset HEAD~1
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
path: ./
token: ${{ secrets.DEPENDABOT_PUBLIC_REPO_ACCESS_TOKEN }}
commit-message: ESLint --fix
committer: openactive-bot <openactive-bot@users.noreply.github.com>
author: openactive-bot <openactive-bot@users.noreply.github.com>
signoff: false
branch: ci/eslint
base: master
delete-branch: true
title: 'ESLint fix'
body: |
Lint fixes based on the latest version of ESLint.
labels: |
automated pr
draft: false
- name: Auto-approve PR
uses: hmarr/auto-approve-action@v3
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge "$PR_URL" --auto --body "" --squash
env:
PR_URL: ${{ steps.cpr.outputs.pull-request-url }}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"