Skip to content

Commit 3e99eb2

Browse files
committed
minor #2564 [CI] Fix dist files base/head informations (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [CI] Fix dist files base/head informations | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT Follows #2563 Commits ------- 5fec9c2 [CI] Fix dist files base/head informations
2 parents 24c4fd3 + 5fec9c2 commit 3e99eb2

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

.github/generate-dist-files-size-diff.mjs

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
Usage:
77
```shell
88
BASE_DIST_FILES='{"src/Autocomplete/assets/dist/controller.js":{"size":15382,"size_gz":3716},"src/Chartjs/assets/dist/controller.js":{"size":2281,"size_gz":771},"src/Cropperjs/assets/dist/controller.js":{"size":1044,"size_gz":475}}' \
9-
PR_DIST_FILES='{"src/Chartjs/assets/dist/controller.js":{"size":1281,"size_gz":171},"src/Cropperjs/assets/dist/controller.js":{"size":1044,"size_gz":475},"src/Cropperjs/assets/dist/style.min.css":{"size":32,"size_gz":66},"src/Dropzone/assets/dist/controller.js":{"size":3199,"size_gz":816},"src/Map/src/Bridge/Google/assets/dist/foo.js":{"size":3199,"size_gz":816}}' \
10-
BASE_REPO_NAME='kocal/symfony-ux' \
11-
BASE_REF_NAME='my-branch-name' \
9+
HEAD_DIST_FILES='{"src/Chartjs/assets/dist/controller.js":{"size":1281,"size_gz":171},"src/Cropperjs/assets/dist/controller.js":{"size":1044,"size_gz":475},"src/Cropperjs/assets/dist/style.min.css":{"size":32,"size_gz":66},"src/Dropzone/assets/dist/controller.js":{"size":3199,"size_gz":816},"src/Map/src/Bridge/Google/assets/dist/foo.js":{"size":3199,"size_gz":816}}' \
10+
HEAD_REPO_NAME='kocal/symfony-ux' \
11+
HEAD_REF='my-branch-name' \
1212
node .github/generate-dist-files-size-diff.mjs
1313
```
1414
*/
@@ -17,16 +17,16 @@ if (!process.env.BASE_DIST_FILES) {
1717
throw new Error('Missing or invalid "BASE_DIST_FILES" env variable.');
1818
}
1919

20-
if (!process.env.PR_DIST_FILES) {
21-
throw new Error('Missing or invalid "PR_DIST_FILES" env variable.');
20+
if (!process.env.HEAD_DIST_FILES) {
21+
throw new Error('Missing or invalid "HEAD_DIST_FILES" env variable.');
2222
}
2323

24-
if (!process.env.BASE_REPO_NAME) {
25-
throw new Error('Missing or invalid "BASE_REPO_NAME" env variable.');
24+
if (!process.env.HEAD_REPO_NAME) {
25+
throw new Error('Missing or invalid "HEAD_REPO_NAME" env variable.');
2626
}
2727

28-
if (!process.env.BASE_REF_NAME) {
29-
throw new Error('Missing or invalid "BASE_REF_NAME" env variable.');
28+
if (!process.env.HEAD_REF) {
29+
throw new Error('Missing or invalid "HEAD_REF" env variable.');
3030
}
3131

3232
/**
@@ -67,11 +67,11 @@ function formatDiffPercent(percent) {
6767
}
6868

6969
export function main() {
70-
const repoUrl = `https://github.com/${process.env.BASE_REPO_NAME}`;
70+
const repoUrl = `https://github.com/${process.env.HEAD_REPO_NAME}`;
7171
/** @type {Record<string, {size: number, size_gz: number}>} */
7272
const base = JSON.parse(process.env.BASE_DIST_FILES);
7373
/** @type {Record<string, {size: number, size_gz: number}>} */
74-
const pr = JSON.parse(process.env.PR_DIST_FILES);
74+
const pr = JSON.parse(process.env.HEAD_DIST_FILES);
7575
let output = '<h1>📊 Packages dist files size difference</h1>\n\n';
7676

7777
/**
@@ -108,7 +108,7 @@ export function main() {
108108
meta: {
109109
packageName,
110110
bridgeName,
111-
url: isBridge ? `${repoUrl}/tree/${process.env.BASE_REF_NAME}/src/${packageName}/src/Bridge/${bridgeName}/assets/dist` : `${repoUrl}/tree/${process.env.BASE_REF_NAME}/src/${packageName}/assets/dist`,
111+
url: isBridge ? `${repoUrl}/tree/${process.env.HEAD_REF}/src/${packageName}/src/Bridge/${bridgeName}/assets/dist` : `${repoUrl}/tree/${process.env.HEAD_REF}/src/${packageName}/assets/dist`,
112112
}, files: new Set(),
113113
});
114114
}
@@ -126,7 +126,7 @@ export function main() {
126126
},
127127
meta: {
128128
fileNameShort: file.replace(isBridge ? `src/${file.split('/')[1]}/src/Bridge/${file.split('/')[4]}/assets/dist/` : `src/${file.split('/')[1]}/assets/dist/`, ''),
129-
fileNameUrl: `${repoUrl}/blob/${process.env.BASE_REF_NAME}/${file}`,
129+
fileNameUrl: `${repoUrl}/blob/${process.env.HEAD_REF}/${file}`,
130130
},
131131
});
132132
}

.github/workflows/dist-files-size-diff.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
uses: actions/github-script@v7
5050
env:
5151
BASE_DIST_FILES: ${{ steps.base-dist-files.outputs.files }}
52-
PR_DIST_FILES: ${{ steps.pr-dist-files.outputs.files }}
53-
BASE_REPO_NAME: ${{ github.event.pull_request.base.repo.full_name }}
54-
BASE_REF_NAME: ${{ github.event.pull_request.base.ref }}
52+
HEAD_DIST_FILES: ${{ steps.pr-dist-files.outputs.files }}
53+
HEAD_REPO_NAME: ${{ github.event.pull_request.head.repo.full_name }}
54+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
5555
with:
5656
result-encoding: string
5757
script: |

0 commit comments

Comments
 (0)