This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
82 lines (72 loc) · 2.56 KB
/
ci-pr.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
# Unique name for this workflow
name: CI on PR
# Definition when the workflow should run
on:
workflow_dispatch:
pull_request:
types: [opened, edited, synchronize, reopened]
# Jobs to be executed
jobs:
format-lint-lwc-tests:
runs-on: ubuntu-latest
steps:
# Checkout the source code
- name: "Checkout source code"
uses: actions/checkout@v2
# Install Volta to enforce proper node and package manager versions
- name: "Install Volta"
uses: volta-cli/action@v1
# Cache node_modules to speed up the process
- name: "Restore node_modules cache"
id: cache-npm
uses: actions/cache@v1
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
# Install npm dependencies for Prettier and Jest
- name: "Install npm dependencies"
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
# Prettier formatting
- name: "Code formatting verification with Prettier"
run: npm run prettier:verify
# Linting
- name: "Linting"
run: npm run lint
# Auto merge Dependabot PRs for:
# - patch updates on prod dependencies
# - minor updates on dev dependencies
dependabot-auto-merge:
# Only run for Dependabot PRs
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
needs: format-lint-lwc-tests
permissions:
pull-requests: write
contents: write
steps:
- name: "Fetch Dependabot metadata"
id: dependabot
uses: dependabot/[email protected]
- name: "Check auto merge conditions"
id: auto-merge
if: |
(
steps.dependabot.outputs.update-type == 'version-update:semver-patch' &&
contains('direct:production,indirect:production', steps.dependabot.outputs.dependency-type)
) || (
contains('version-update:semver-minor,version-update:semver-patch', steps.dependabot.outputs.update-type) &&
contains('direct:development,indirect:development', steps.dependabot.outputs.dependency-type)
)
run: echo "::notice ::auto-merge conditions satisfied"
- name: "Approve and merge PR"
if: ${{ steps.auto-merge.conclusion == 'success' }}
run: |
gh pr review --approve "$PR_URL"
gh pr merge --auto --rebase "$PR_URL"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}