-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 2.34 KB
/
dependabot-pr-nx-lint-fix.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
name: Dependabot PR NX Lint Fix
on:
workflow_call:
jobs:
dependabot-pr-nx-lint-fix:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v3
with:
# By default, PRs will be checked-out based on the Merge Commit, but we want the actual branch HEAD.
ref: ${{ github.event.pull_request.head.sha }}
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3
with:
main-branch-name: "main"
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "yarn"
- name: Print node/npm/yarn versions
id: versions
run: |
node_ver=$( node --version )
yarn_ver=$( yarn --version || true )
echo "Node: ${node_ver:1}"
echo "NPM: $( npm --version )"
if [[ $yarn_ver != '' ]]; then echo "Yarn: $yarn_ver"; fi
echo "node_version=${node_ver:1}" >> $GITHUB_OUTPUT
echo "yarn_version=${yarn_ver}" >> $GITHUB_OUTPUT
- name: Get yarn cache directory path [yarn berry]
id: yarn-berry-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Use the node_modules cache if available [yarn berry]
uses: actions/cache@v3
with:
path: ${{ steps.yarn-berry-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-yarn-berry-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-yarn-berry-
- run: yarn install --immutable
- run: yarn nx affected --target=lint --fix
- name: Commit files
run: |
git config --local user.email "dependabot[bot]@users.noreply.github.com"
git config --local user.name "dependabot[bot]"
git add .
git commit --amend --no-edit --no-verify
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}
force: true
github_token: ${{ secrets.GITHUB_TOKEN }}