Skip to content

Commit c039387

Browse files
committed
[CI] Fix links to changed dist files
1 parent feb0256 commit c039387

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ 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}}' \
99
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-
GITHUB_REPOSITORY='symfony/ux' \
11-
GITHUB_HEAD_REF='my-branch-name' \
10+
BASE_REPO_NAME='kocal/symfony-ux' \
11+
BASE_REF_NAME='my-branch-name' \
1212
node .github/generate-dist-files-size-diff.mjs
1313
```
1414
*/
@@ -21,12 +21,12 @@ if (!process.env.PR_DIST_FILES) {
2121
throw new Error('Missing or invalid "PR_DIST_FILES" env variable.');
2222
}
2323

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

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

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

6969
export function main() {
70-
const repoUrl = `https://github.com/${process.env.GITHUB_REPOSITORY}`;
70+
const repoUrl = `https://github.com/${process.env.BASE_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}>} */
@@ -108,7 +108,7 @@ export function main() {
108108
meta: {
109109
packageName,
110110
bridgeName,
111-
url: isBridge ? `${repoUrl}/tree/${process.env.GITHUB_HEAD_REF}/src/${packageName}/src/Bridge/${bridgeName}/assets/dist` : `${repoUrl}/tree/${process.env.GITHUB_HEAD_REF}/src/${packageName}/assets/dist`,
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`,
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.GITHUB_HEAD_REF}/${file}`,
129+
fileNameUrl: `${repoUrl}/blob/${process.env.BASE_REF_NAME}/${file}`,
130130
},
131131
});
132132
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ jobs:
5050
env:
5151
BASE_DIST_FILES: ${{ steps.base-dist-files.outputs.files }}
5252
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: ${{ env.GITHUB_HEAD_REF }}
5355
with:
5456
result-encoding: string
5557
script: |

0 commit comments

Comments
 (0)