File tree Expand file tree Collapse file tree 5 files changed +78
-191
lines changed
Expand file tree Collapse file tree 5 files changed +78
-191
lines changed Original file line number Diff line number Diff line change 1+ name : Preview
2+ on :
3+ pull_request :
4+ types : [opened, synchronize]
5+
6+ jobs :
7+ preview :
8+ name : Publish Previews
9+ runs-on : ubuntu-latest
10+ steps :
11+ - uses : actions/checkout@v4
12+ with :
13+ fetch-depth : 0
14+ - uses : denoland/setup-deno@v2
15+ with :
16+ deno-version : v2.x
17+ - uses : actions/setup-node@v4
18+ with :
19+ node-version : 20.x
20+
21+ - name : Get changed packages
22+ id : changed
23+ run : deno run -A tasks/preview-matrix.ts
24+
25+ - name : Build and publish previews
26+ if : steps.changed.outputs.workspaces != ''
27+ run : |
28+ for workspace in ${{ steps.changed.outputs.workspaces }}; do
29+ deno run -A tasks/build-npm.ts "$workspace"
30+ done
31+
32+ dirs=""
33+ for workspace in ${{ steps.changed.outputs.workspaces }}; do
34+ dirs="$dirs ./$workspace/build/npm"
35+ done
36+ npx pkg-pr-new publish $dirs
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { main , until } from "effection" ;
2+ import { exec } from "../process/mod.ts" ;
3+ import { readPackages } from "./lib/read-packages.ts" ;
4+
5+ await main ( function * ( ) {
6+ let packages = yield * readPackages ( ) ;
7+
8+ // Get the base branch from GitHub Actions environment
9+ let baseBranch = Deno . env . get ( "GITHUB_BASE_REF" ) || "main" ;
10+
11+ // Get list of changed files compared to base branch
12+ let { stdout } = yield * exec (
13+ `git diff --name-only origin/${ baseBranch } ...HEAD` ,
14+ ) . join ( ) ;
15+ let changedFiles = stdout . trim ( ) . split ( "\n" ) . filter ( Boolean ) ;
16+
17+ let workspaces : string [ ] = [ ] ;
18+
19+ for ( let pkg of packages ) {
20+ // Check if any changed file is within this package's workspace
21+ let hasChanges = changedFiles . some ( ( file ) =>
22+ file . startsWith ( `${ pkg . workspace } /` )
23+ ) ;
24+
25+ if ( hasChanges ) {
26+ workspaces . push ( pkg . workspace ) ;
27+ }
28+ }
29+
30+ let outputValue = `workspaces=${ workspaces . join ( " " ) } ` ;
31+
32+ console . log ( outputValue ) ;
33+
34+ if ( Deno . env . has ( "GITHUB_OUTPUT" ) ) {
35+ const githubOutput = Deno . env . get ( "GITHUB_OUTPUT" ) as string ;
36+ yield * until (
37+ Deno . writeTextFile ( githubOutput , outputValue , {
38+ append : true ,
39+ } ) ,
40+ ) ;
41+ }
42+ } ) ;
You can’t perform that action at this time.
0 commit comments