Skip to content

Commit

Permalink
debug: test integrate script
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmcguin committed Aug 22, 2024
1 parent d313d3e commit 48c9324
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ on:

jobs:
prepare:
name: Prepare Matrix Output
name: Prepare Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{steps.matrix.outputs.matrix}}
steps:
- name: Checkout
uses: actions/checkout@v3

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

# doesn't work with "act"
- name: Packages Changed
id: changes
with:
Expand All @@ -24,12 +22,13 @@ jobs:
deps:
- 'package.json'
sites:
- 'sites/**'
- 'sites/!(template/**)/**'
packages:
- 'packages/**'
uses: dorny/paths-filter@v3

- name: Transform Sites Changed
id: transformed-changes
run: |
sites=()
Expand All @@ -40,17 +39,20 @@ jobs:
unique_sites=($(printf "%s\n" "${sites[@]}" | sort -u))
echo "SITES_CHANGED=${unique_sites[@]}" >> $GITHUB_ENV
echo "FILES_CHANGED=${{ steps.changes.outputs }}" >> $GITHUB_ENV
- name: Inspect Packages Changed
run: |
echo "Outputs: ${{ toJSON(steps.changes.outputs) }}"
echo "Changes: ${{ steps.changes.outputs.changes }}"
echo "Packages Changed: ${{ steps.changes.outputs.sites_files }}"
# echo "DEPS_DID_CHANGE=${{ steps.changes.outputs.deps}}" >> $GITHUB_ENV
# echo "PACKAGES_DID_CHANGE=${{ steps.changes.outputs.packages}}" >> $GITHUB_ENV
# echo "SITES_DID_CHANGE=${{ steps.changes.outputs.sites}}" >> $GITHUB_ENV
- name: Build Dynamic Matrix
if: ${{ steps.changes.outputs.sites }}
id: matrix
run: node scripts/build_sites.mjs
run: |
if [[ ${{ steps.changes.outputs.packages }} == true ] || [ ${{ steps.changes.outputs.deps == true }} ]]; then
node scripts/build_matrix.mjs --all
else
node scripts/build_sites.mjs
fi
# 1. get the packages changed
# 2. If the core package was changed, deploy all sites
# 3. If only a certain site OR sites was changed, only deploy those sites.
Expand Down
15 changes: 12 additions & 3 deletions scripts/build_sites.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,29 @@ import { appendFileSync } from "node:fs";
import { argv, env, exit } from "node:process";
import * as os from "node:os";

console.log("ENV IS", env);
const { SITES, SITES_CHANGED } = env;

try {
const SITES = env.SITES;
const [_node, _script, ...userArgs] = argv;
const doBuildAll = userArgs.some((arg) => arg === "--all");
if (!SITES) {
throw new Error("Needs SITES set. Are you missing the sites.json file?");
}

const allSites = JSON.parse(SITES);
/**
* Core dependencies or a common package changed.
* Rebuild all sites.
* */
if (DEPS_DID_CHANGE || PACKAGES_DID_CHANGE) {
}

/**
* process.env.SITES is the user defined list of all sites.
*
* This is a key value pair where keys are the package name in the monorepo
* and values are the corresponding project name for the website in Cloudflare
* */
const allSites = JSON.parse(SITES);
for (const [key, value] of Object.entries(allSites)) {
console.log({ key, value });
}
Expand Down
8 changes: 8 additions & 0 deletions scripts/new_site.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import { rimraf } from "rimraf";
import ora from "ora";

import Logger from "./utils/logger.mjs";
// import { Command } from "commander";

// const program = new Command();
// program
// .name("Build Matrix")
// .description("Script to build out the matrix of sites to deploy")
// .version("0.1.0")
// .option("-a, --all", "All sites");

const execP = promisify(exec);

Expand Down

0 comments on commit 48c9324

Please sign in to comment.