Skip to content

Commit d4afb85

Browse files
feat: use boilerplate for GH Actions and remove build (#116)
1 parent 1067a09 commit d4afb85

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ templates/**/package-lock.json
4545
/playwright/.cache/
4646

4747
# We generate this on publish
48-
boilerplate
48+
boilerplate/functions

src/templates/github-actions.ts renamed to boilerplate/github/deploy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
export const GITHUB_ACTION_DEPLOY = `name: Deploy to Juno
1+
name: Deploy to Juno
22

33
on:
44
workflow_dispatch:
55
push:
66
branches: [main]
77

88
jobs:
9-
build:
9+
publish:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Check out the repo
@@ -25,4 +25,4 @@ jobs:
2525
with:
2626
args: deploy
2727
env:
28-
JUNO_TOKEN: $\{{ secrets.JUNO_TOKEN }}`
28+
JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }}

scripts/cli-to-boilerplate.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ set -e
55
NPM_ROOT=$(npm root -g)
66
SRC="$NPM_ROOT/@junobuild/cli/templates/eject"
77

8-
DEST="./boilerplate"
9-
DEST_FUNCTIONS="$DEST/functions"
8+
DEST="./boilerplate/functions"
109

1110
if [ -d "$DEST" ]; then
1211
rm -rf "$DEST"
1312
fi
1413

15-
mkdir -p "$DEST_FUNCTIONS"
14+
mkdir -p "$DEST"
1615

17-
cp -r "$SRC/"* "$DEST_FUNCTIONS/"
16+
cp -r "$SRC/"* "$DEST/"
1817

1918
echo "✅ Boilerplate copied to $DEST"

src/services/generate.services.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import {writeFile} from 'node:fs/promises';
66
import {basename, join, parse} from 'node:path';
77
import ora from 'ora';
88
import {BOILERPLATE_PATH, JUNO_CDN_URL} from '../constants/constants';
9-
import {GITHUB_ACTION_DEPLOY} from '../templates/github-actions';
109
import type {PopulateInput, ServerlessFunctions} from '../types/generator';
1110
import {untarFile, type UntarOutputFile} from '../utils/compress.utils';
1211
import {
1312
copyFiles,
13+
createFolders,
1414
createParentFolders,
1515
getLocalTemplatePath,
1616
getRelativeTemplatePath
@@ -125,11 +125,13 @@ const populateFromLocal = async ({where, template, localDevelopment}: PopulateIn
125125
};
126126

127127
const populateGitHubAction = async ({where}: PopulateInputFn) => {
128-
const target = join(where ?? '', '.github', 'workflows', 'deploy.yaml');
128+
const target = join(where ?? '', '.github', 'workflows');
129129

130-
createParentFolders(target);
130+
createFolders(target);
131131

132-
await writeFile(target, GITHUB_ACTION_DEPLOY);
132+
const source = join(BOILERPLATE_PATH, 'github');
133+
134+
await copyFiles({source, target});
133135
};
134136

135137
const updatePackageJson = async ({

src/utils/fs.utils.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ export const getLocalTemplatePath = ({key}: {key: TemplateKey}) =>
1717
export const createParentFolders = (target: string) => {
1818
const folder = dirname(target);
1919

20-
if (!existsSync(folder)) {
21-
mkdirSync(folder, {recursive: true});
20+
createFolders(folder);
21+
};
22+
23+
export const createFolders = (folder: string) => {
24+
if (existsSync(folder)) {
25+
return;
2226
}
27+
28+
mkdirSync(folder, {recursive: true});
2329
};
2430

2531
export const copyFiles = async ({source, target}: {source: string; target: string}) => {

0 commit comments

Comments
 (0)