Skip to content

Commit

Permalink
Merge pull request #15 from Sauloxd/issue-9/optional-build-cmd
Browse files Browse the repository at this point in the history
[Issue-9] Skip build cmd
  • Loading branch information
Sauloxd authored Dec 28, 2021
2 parents 34ff518 + 7906c69 commit 2309871
Show file tree
Hide file tree
Showing 40 changed files with 98 additions and 823 deletions.
35 changes: 20 additions & 15 deletions .github/workflows/for-testing-this-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
# https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#pull_request
pull_request:
types: [labeled, unlabeled, opened, edited, closed, synchronize]
# push:
# branches:
# - issue-**

jobs:
develop:
Expand All @@ -24,8 +27,10 @@ jobs:
- name: Install deps checking cache hit
run: yarn install --frozen-lockfile

# Use this action to SSH to github action machine.
# - name: Setup tmate session (ssh)
# uses: mxschmitt/action-tmate@v2

# This is how you'll use the action
- name: Building create-react-app example
uses: ./ # Replace here with sauloxd/[email protected]
Expand All @@ -36,19 +41,19 @@ jobs:
slug: 'dev-cra'

# This is how you'll use the action
# - name: Building storybook example
# uses: ./ # Replace here with sauloxd/[email protected]
# with:
# build-cmd: 'yarn run cra:storybook'
# branch: 'review-apps'
# dist: 'packages/cra-example/storybook-static'
# slug: 'dev-cra-sb'
- name: Building storybook example
uses: ./ # Replace here with sauloxd/[email protected]
with:
build-cmd: 'yarn run cra:storybook'
branch: 'review-apps'
dist: 'packages/cra-example/storybook-static'
slug: 'dev-cra-sb'

# # This is how you'll use the action
# - name: Building gatsby example
# uses: ./ # Replace here with sauloxd/[email protected]
# with:
# build-cmd: 'yarn run gatsby:build'
# branch: 'review-apps'
# dist: 'packages/gatsby-example/public'
# slug: 'dev-gatsby'
# This is how you'll use the action
- name: Building gatsby example
uses: ./ # Replace here with sauloxd/[email protected]
with:
build-cmd: 'yarn run gatsby:build'
branch: 'review-apps'
dist: 'packages/gatsby-example/public'
slug: 'dev-gatsby'
5 changes: 3 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: |
runs:
using: 'node16'
main: 'packages/action/dist/src/index.js'
main: 'packages/action/dist/index.js'

inputs:
build-cmd:
Expand All @@ -13,7 +13,8 @@ inputs:
For example, if you use "create-react-app", this would be "yarn build".
IMPORTANT: If your app doesn't use HashRouting (the #/ in url), use process.env.PUBLIC_URL to correctly configure it.
See FAQ and https://www.gatsbyjs.com/docs/path-prefix/ for more info.
default: 'yarn build'
Also you can skip building your apps if you did it in a previous step.
Remember that the "dist" path should be pointing to your app's build
branch:
description: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"private": "true",
"version": "0.0.1",
"main": "packages/action/dist/src/index.js",
"main": "packages/action/dist/index.js",
"repository": "[email protected]:Sauloxd/review-apps.git",
"author": "sauloxd <[email protected]>",
"license": "MIT",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,17 @@ const log_error_1 = require("../utils/log-error");
const user_input_1 = require("../utils/user-input");
exports.syncApp = (0, log_error_1.withError)(function syncApp(params) {
return __awaiter(this, void 0, void 0, function* () {
const paths = fileManager.paths(params);
const input = (0, user_input_1.userInput)();
const PUBLIC_URL = `/${paths.byRepo}/${paths.byHeadCommit}`;
const paths = fileManager.paths(params);
core.info(`
-> Paths:
-> Your app will be hosted in github pages:
-> "https://${params.repository.owner}.github.io/${params.repository.name}"
-> This app is served from:
-> "https://${params.repository.owner}.github.io/${params.repository.name}/${paths.byHeadCommit}"
-> We'll build your app with the proper PUBLIC_URL: ${PUBLIC_URL}
-> For more info:
-> https://github.com/facebook/create-react-app/pull/937/files#diff-9b26877ecf8d15b7987c96e5a17502f6
-> https://www.gatsbyjs.com/docs/path-prefix/
`);
core.info(`
-> Building app
`);
yield git.hardReset(params.branch.name);
core.exportVariable('PUBLIC_URL', PUBLIC_URL);
yield (0, exec_1.exec)(input.buildCmd);
yield optionalBuildApp(params);
core.info(`
-> Current working branch: ${params.branch.name}"
-> Will move (and override) the build result on '${input.dist}' to '${paths.byHeadCommit}' in ${input.branch}"
Expand Down Expand Up @@ -89,3 +81,28 @@ function updateApp(params) {
yield git.push(input.branch);
});
}
function optionalBuildApp(params) {
return __awaiter(this, void 0, void 0, function* () {
const input = (0, user_input_1.userInput)();
if (!input.buildCmd) {
core.info(`
-> NO "buildCmd" passed, skipping build phase
`);
return;
}
const paths = fileManager.paths(params);
const PUBLIC_URL = `/${paths.byRepo}/${paths.byHeadCommit}`;
core.info(`
-> BUILDING APP
-> We'll build your app with the proper PUBLIC_URL: ${PUBLIC_URL}
-> That way you can use relative links inside your app.
-> For more info:
-> https://github.com/facebook/create-react-app/pull/937/files#diff-9b26877ecf8d15b7987c96e5a17502f6
-> https://www.gatsbyjs.com/docs/path-prefix/
`);
yield git.hardReset(params.branch.name);
core.exportVariable('PUBLIC_URL', PUBLIC_URL);
yield (0, exec_1.exec)(input.buildCmd);
});
}
41 changes: 0 additions & 41 deletions packages/action/dist/spec/fixtures/manifest.js

This file was deleted.

Loading

0 comments on commit 2309871

Please sign in to comment.