-
Notifications
You must be signed in to change notification settings - Fork 198
82 lines (80 loc) · 3.49 KB
/
dependencies-report.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
name: WordPress Dependencies Report
on:
pull_request:
jobs:
build-trunk:
runs-on: ubuntu-latest
name: Build trunk for Dependencies Report
steps:
- uses: actions/checkout@v4
with:
ref: trunk
- shell: bash
name: Get trunk latest commit
id: trunk-commit
run: |
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: dist-cache
with:
path: ${{ github.workspace }}/assets/dist
key: ${{ runner.os }}-dist-${{ steps.trunk-commit.outputs.commit }}
if: steps.dist-cache.outputs.cache-hit != 'true'
- name: Get npm cache directory
id: npm-cache
if: steps.dist-cache.outputs.cache-hit != 'true'
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
if: steps.dist-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install JS dependencies
run: npm ci
if: steps.dist-cache.outputs.cache-hit != 'true'
- name: Create default dist folder
run: mkdir -p ${{ github.workspace }}/assets/dist && echo "{}" > ${{ github.workspace }}/assets/dist/assets.json
if: steps.dist-cache.outputs.cache-hit != 'true'
- name: Build Combined Assets for Trunk
run: npm run build:combine-assets
if: steps.dist-cache.outputs.cache-hit != 'true'
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: combined-assets
path: ${{ github.workspace }}/assets/dist
dependencies-report:
needs: [ build-trunk ]
name: WordPress Dependencies Report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get npm cache directory
id: npm-cache
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install JS dependencies
run: npm ci
- name: Build Combined Assets
run: npm run build:combine-assets
- name: Download assets (trunk)
uses: actions/download-artifact@v4
with:
name: combined-assets
path: dist-trunk
- name: Analyze dependencies and publish report
uses: Automattic/github-action-wordpress-dependencies-report@v0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
old-assets-folder: ${{ github.workspace }}/dist-trunk
old-assets-branch: trunk
new-assets-folder: ${{ github.workspace }}/assets/dist