Skip to content

Commit 31a3aad

Browse files
committed
debug: test paths-filter input to script
1 parent 5261c23 commit 31a3aad

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

.github/workflows/publish.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v3
1414

15-
# - name: Setting SITES
16-
# run: echo "SITES=$(jq -c . < sites.json)" >> $GITHUB_ENV
15+
- name: Setting SITES
16+
run: echo "SITES=$(jq -c . < sites.json)" >> $GITHUB_ENV
1717

1818
# doesn't work with "act"
1919
- name: Packages Changed
@@ -33,23 +33,24 @@ jobs:
3333
run: |
3434
sites=()
3535
36-
# for filepath in "${filepaths[@]}"; do
3736
for filepath in ${{ steps.changes.outputs.sites_files }}; do
3837
dir=$(echo "$filepath" | cut -d'/' -f2)
3938
sites+=("$dir")
4039
done
4140
4241
unique_sites=($(printf "%s\n" "${sites[@]}" | sort -u))
43-
echo "SITES is: ${unique_sites[@]}"
42+
echo "SITES_CHANGED=${unique_sites[@]}" >> $GITHUB_ENV
43+
echo "FILES_CHANGED=${{ toJSON(steps.changes.outputs) }}" >> $GITHUB_ENV
4444
4545
- name: Inspect Packages Changed
4646
run: |
4747
echo "Outputs: ${{ toJSON(steps.changes.outputs) }}"
4848
echo "Changes: ${{ steps.changes.outputs.changes }}"
4949
echo "Packages Changed: ${{ steps.changes.outputs.sites_files }}"
50-
# - name: Build Dynamic Matrix
51-
# id: matrix
52-
# run: node scripts/build_sites.mjs
50+
51+
- name: Build Dynamic Matrix
52+
id: matrix
53+
run: node scripts/build_sites.mjs
5354
# 1. get the packages changed
5455
# 2. If the core package was changed, deploy all sites
5556
# 3. If only a certain site OR sites was changed, only deploy those sites.

scripts/build_sites.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* This script is used to build out the websites that should be deployed
3+
* */
4+
import { appendFileSync } from "node:fs";
5+
import { argv, env, exit } from "node:process";
6+
import * as os from "node:os";
7+
8+
console.log("ENV IS", env);
9+
try {
10+
const SITES = env.SITES;
11+
if (!SITES) {
12+
throw new Error("Needs SITES set. Are you missing the sites.json file?");
13+
}
14+
15+
/**
16+
* process.env.SITES is the user defined list of all sites.
17+
*
18+
* This is a key value pair where keys are the package name in the monorepo
19+
* and values are the corresponding project name for the website in Cloudflare
20+
* */
21+
const allSites = JSON.parse(SITES);
22+
for (const [key, value] of Object.entries(allSites)) {
23+
console.log({ key, value });
24+
}
25+
} catch (error) {
26+
console.error("Error building sites", error);
27+
exit(1);
28+
}
29+
30+
// const matrix = {
31+
// include: [
32+
// {
33+
// project: "unicorn-demo",
34+
// package: "unicorn-demo",
35+
// },
36+
// ],
37+
// };
38+
//
39+
// appendFileSync(
40+
// process.env.GITHUB_OUTPUT,
41+
// `matrix=${JSON.stringify(matrix)}${os.EOL}`
42+
// );

sites.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"unicorn-demo": "unicorn-demo"
3+
}

0 commit comments

Comments
 (0)