Skip to content

Commit b08c46a

Browse files
committed
Just commit the built actions instead
1 parent 85773b0 commit b08c46a

File tree

5 files changed

+92
-31
lines changed

5 files changed

+92
-31
lines changed

.github/actions/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!dist/*.js

.github/actions/dist/info.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// src/info/index.ts
2+
import fs from "fs/promises";
3+
import pathlib from "path";
4+
import * as core from "@actions/core";
5+
import { getExecOutput } from "@actions/exec";
6+
async function findPackages(directory, maxDepth) {
7+
const output = [];
8+
async function* recurser(currentDir, currentDepth) {
9+
if (maxDepth !== void 0 && currentDepth >= maxDepth) return;
10+
const items = await fs.readdir(currentDir, { withFileTypes: true });
11+
for (const item of items) {
12+
const fullPath = pathlib.join(currentDir, item.name);
13+
if (item.isFile()) {
14+
if (item.name === "package.json") {
15+
try {
16+
const { default: { name } } = await import(fullPath, { with: { type: "json" } });
17+
if (name) {
18+
yield { name, directory: currentDir };
19+
return;
20+
}
21+
;
22+
} catch {
23+
}
24+
}
25+
continue;
26+
}
27+
if (item.isDirectory() && item.name !== "node_modules" && !item.name.startsWith("__")) {
28+
yield* recurser(fullPath, currentDepth + 1);
29+
}
30+
}
31+
}
32+
for await (const each of recurser(directory, 0)) {
33+
output.push(each);
34+
}
35+
return output;
36+
}
37+
async function main() {
38+
const { stdout } = await getExecOutput("git", ["rev-parse", "--show-toplevel"]);
39+
const gitRoot = stdout.trim();
40+
const packageType = core.getInput("type", { required: true });
41+
let dirPath;
42+
switch (packageType) {
43+
case "libs": {
44+
dirPath = pathlib.join(gitRoot, "lib");
45+
break;
46+
}
47+
case "bundles": {
48+
dirPath = pathlib.join(gitRoot, "src", "bundles");
49+
break;
50+
}
51+
case "tabs": {
52+
dirPath = pathlib.join(gitRoot, "src", "tabs");
53+
break;
54+
}
55+
default: {
56+
core.error(`Invalid package type: ${packageType}. Must be lib, bundles or tabs`);
57+
return;
58+
}
59+
}
60+
const packages = await findPackages(dirPath);
61+
core.setOutput(packageType, packages);
62+
core.summary.addHeading(`Found ${packageType}`);
63+
core.summary.addList(packages.map(({ name }) => name));
64+
core.summary.write();
65+
}
66+
try {
67+
await main();
68+
} catch (error2) {
69+
core.setFailed(error2.message);
70+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// src/install-deps/index.ts
2+
import * as core from "@actions/core";
3+
import { exec } from "@actions/exec";
4+
async function main() {
5+
const packageName = core.getInput("packageName");
6+
const directory = core.getInput("directory");
7+
const testRequired = core.getBooleanInput("testRequired");
8+
const args = ["workspaces", "focus", packageName];
9+
if (!testRequired) {
10+
args.push("--production");
11+
}
12+
await exec("yarn", args);
13+
const { default: packageJson } = await import(`${directory}/package.json`, { with: { type: "json" } });
14+
if (testRequired && packageJson.devDependecies) {
15+
core.info(`Playwright is necessary for ${packageName}, installing`);
16+
await exec("yarn", ["playwright", "install", "--with-deps"]);
17+
}
18+
}
19+
await main();

.github/actions/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"type": "module",
55
"devDependencies": {
66
"@types/node": "^22.15.30",
7+
"@sourceacademy/modules-repotools": "workspace:^",
78
"typescript": "^5.8.2"
89
},
910
"dependencies": {
1011
"@actions/core": "^1.11.1",
11-
"@actions/exec": "^1.1.1",
12-
"@sourceacademy/modules-repotools": "workspace:^"
12+
"@actions/exec": "^1.1.1"
1313
},
1414
"scripts": {
1515
"build": "node ./build.js"

.github/workflows/new-workflow.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,8 @@ on:
99
- master
1010

1111
jobs:
12-
build-actions:
13-
name: Builds the github actions that will be used
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Check out source code
17-
uses: actions/checkout@v4
18-
19-
- name: Enable Corepack
20-
run: corepack enable
21-
22-
- name: Use Node.js 💻
23-
uses: actions/setup-node@v4
24-
with:
25-
node-version-file: .node-version
26-
cache: yarn
27-
28-
- name: Setup repotools
29-
run: |
30-
yarn workspaces focus @sourceacademy/modules-repotools
31-
yarn workspaces foreach -A --include @sourceacademy/modules-repotools run build
32-
33-
- name: Install dependencies
34-
run: yarn workspaces focus @sourceacademy/modules-github-actions
35-
36-
- name: Build
37-
run: |
38-
yarn workspaces foreach -A --include @sourceacademy/modules-github-actions run build
39-
4012
load-packages:
4113
name: Determine the packages present in the repo for the given type
42-
needs: build-actions
4314
runs-on: ubuntu-latest
4415
strategy:
4516
matrix:

0 commit comments

Comments
 (0)