Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ jobs:
build_configuration: # The branch the action should deploy from.
base_href: /angular-deploy-gh-pages-actions/
deploy_branch: gh-pages # The branch the action should deploy to.
deploy_folder: ./
angular_dist_build_folder: jokester/dist/jokester # The folder the action should deploy.
angular_project_dir: jokester
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
build_configuration: staging # The build environment for the app. please look configurations in your angular.json
base_href: /my-project/ # make sure this corresponds to https://<your_username>.github.io/<base_href>/
deploy_branch: gh-pages # The branch the action should deploy to.
deploy_folder: ./ # The deploy fold
angular_dist_build_folder: dist/my-project # The folder where your project is supposed to be after running ng build by the action.
```

Expand All @@ -48,6 +49,7 @@ You have to configure the `with` portion of your workflow file so that the actio
| `build_configuration` | You can provide the configuration using which the action should create the build. If nothing is provided, it will run `ng build --prod` by default. See your angular.json file for configurations. | `with` | **Yes** | "production" |
| `base_href` | Since gh-pages will deploy the app for https://yourgithubusername.github.io/repositoryname/, you need to provide this `base-href` in order to have your project working correctly, since the base-href won't be `'/'` in this case. Note to use with `@angular/cli@^10.0.0` (Angular version 10), you need the specify the base-href in the angular.json file and then use an empty string as parameter `base_href: '' # empty string to support optional base-href` to make the parameter optional. | `with` | **No** | "/" |
| `deploy_branch` | The branch to which we'll deploy the build folder. | `with` | **No** | "gh-pages" |
| `deploy_folder` | The folder to which we'll deploy the build folder. | `with` | **No** | "./" |
| `angular_dist_build_folder` | The folder in which `ng build` provides its output for your project. The folder where your index.html resides in. Also, this is the folder which will be deployed to the `deploy_branch`. | `with` | **No** | "dist" |
| `run_lint` | Runs the `ng lint` command behind the scenes to make sure the files are linted properly. | `with` | **No** | "false" |
| `github_access_token` | Depending on the repository permissions you may need to provide the action with a GitHub personal access token instead of the provided GitHub token in order to deploy. You can [learn more about how to generate one here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). **This should be stored as a secret**. | `secrets / with` | **Yes** |
Expand Down
8 changes: 6 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ test('test throws error for deployment if accessToken is not provided', async ()
const accessToken = ''
const buildFolder = './dist/my-app'
const deployBranch = 'my-custom-branch'
const deployFolder = './target'
process.env['execute_success'] = 'true'
await expect(
deployBuild({
accessToken,
buildFolder,
deployBranch
deployBranch,
deployFolder
})
).rejects.toThrow(
'Github Access token not provided. Please add it to your workflow yml'
Expand All @@ -41,11 +43,13 @@ test('test runs fine for deployment if all inputs are correct', async () => {
const accessToken = 'some-token'
const buildFolder = './dist/my-app'
const deployBranch = 'my-custom-branch'
const deployFolder = './target'
process.env['execute_success'] = 'true'
const result = await deployBuild({
accessToken,
buildFolder,
deployBranch
deployBranch,
deployFolder
})
expect(result).toBe('successfully deployed')
})
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ inputs:
deploy_branch:
description: "branch on which the angular build will be deployed"
default: "gh-pages"
deploy_folder:
description: "This is the folder which will be deployed to the `deploy_branch`."
default: "./"
angular_dist_build_folder:
description: "The folder in which `ng build` provides its output. This is the folder which will be deployed to the `deploy_branch`."
description: "The folder in which `ng build` provides its output."
default: "dist"
run_lint:
description: "If the action should run 'ng lint'"
Expand Down
9 changes: 6 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3818,6 +3818,7 @@ function run() {
const shouldRunLint = core_1.getInput('run_lint');
const accessToken = core_1.getInput('github_access_token');
const buildFolder = core_1.getInput('angular_dist_build_folder');
const deployFolder = core_1.getInput('deploy_folder');
const angularProjectDir = core_1.getInput('angular_project_dir');
const deployBranch = core_1.getInput('deploy_branch');
// if the angular project directory is not the current directory
Expand All @@ -3844,7 +3845,8 @@ function run() {
yield commands.deployBuild({
accessToken,
buildFolder,
deployBranch
deployBranch,
deployFolder
});
}
catch (error) {
Expand Down Expand Up @@ -3893,7 +3895,7 @@ exports.getUserAgent = getUserAgent;
/***/ 215:
/***/ (function(module) {

module.exports = {"_args":[["@octokit/rest@16.43.1","/Users/ahsanayaz/Contributions/angular-deploy-gh-pages-actions"]],"_from":"@octokit/rest@16.43.1","_id":"@octokit/rest@16.43.1","_inBundle":false,"_integrity":"sha512-gfFKwRT/wFxq5qlNjnW2dh+qh74XgTQ2B179UX5K1HYCluioWj8Ndbgqw2PVqa1NnVJkGHp2ovMpVn/DImlmkw==","_location":"/@octokit/rest","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"@octokit/rest@16.43.1","name":"@octokit/rest","escapedName":"@octokit%2frest","scope":"@octokit","rawSpec":"16.43.1","saveSpec":null,"fetchSpec":"16.43.1"},"_requiredBy":["/@actions/github"],"_resolved":"https://registry.npmjs.org/@octokit/rest/-/rest-16.43.1.tgz","_spec":"16.43.1","_where":"/Users/ahsanayaz/Contributions/angular-deploy-gh-pages-actions","author":{"name":"Gregor Martynus","url":"https://github.com/gr2m"},"bugs":{"url":"https://github.com/octokit/rest.js/issues"},"bundlesize":[{"path":"./dist/octokit-rest.min.js.gz","maxSize":"33 kB"}],"contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"dependencies":{"@octokit/auth-token":"^2.4.0","@octokit/plugin-paginate-rest":"^1.1.1","@octokit/plugin-request-log":"^1.0.0","@octokit/plugin-rest-endpoint-methods":"2.4.0","@octokit/request":"^5.2.0","@octokit/request-error":"^1.0.2","atob-lite":"^2.0.0","before-after-hook":"^2.0.0","btoa-lite":"^1.0.0","deprecation":"^2.0.0","lodash.get":"^4.4.2","lodash.set":"^4.3.2","lodash.uniq":"^4.5.0","octokit-pagination-methods":"^1.1.0","once":"^1.4.0","universal-user-agent":"^4.0.0"},"description":"GitHub REST API client for Node.js","devDependencies":{"@gimenete/type-writer":"^0.1.3","@octokit/auth":"^1.1.1","@octokit/fixtures-server":"^5.0.6","@octokit/graphql":"^4.2.0","@types/node":"^13.1.0","bundlesize":"^0.18.0","chai":"^4.1.2","compression-webpack-plugin":"^3.1.0","cypress":"^3.0.0","glob":"^7.1.2","http-proxy-agent":"^4.0.0","lodash.camelcase":"^4.3.0","lodash.merge":"^4.6.1","lodash.upperfirst":"^4.3.1","lolex":"^5.1.2","mkdirp":"^1.0.0","mocha":"^7.0.1","mustache":"^4.0.0","nock":"^11.3.3","npm-run-all":"^4.1.2","nyc":"^15.0.0","prettier":"^1.14.2","proxy":"^1.0.0","semantic-release":"^17.0.0","sinon":"^8.0.0","sinon-chai":"^3.0.0","sort-keys":"^4.0.0","string-to-arraybuffer":"^1.0.0","string-to-jsdoc-comment":"^1.0.0","typescript":"^3.3.1","webpack":"^4.0.0","webpack-bundle-analyzer":"^3.0.0","webpack-cli":"^3.0.0"},"files":["index.js","index.d.ts","lib","plugins"],"homepage":"https://github.com/octokit/rest.js#readme","keywords":["octokit","github","rest","api-client"],"license":"MIT","name":"@octokit/rest","nyc":{"ignore":["test"]},"publishConfig":{"access":"public"},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"repository":{"type":"git","url":"git+https://github.com/octokit/rest.js.git"},"scripts":{"build":"npm-run-all build:*","build:browser":"npm-run-all build:browser:*","build:browser:development":"webpack --mode development --entry . --output-library=Octokit --output=./dist/octokit-rest.js --profile --json > dist/bundle-stats.json","build:browser:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=Octokit --output-path=./dist --output-filename=octokit-rest.min.js --devtool source-map","build:ts":"npm run -s update-endpoints:typescript","coverage":"nyc report --reporter=html && open coverage/index.html","generate-bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","lint":"prettier --check '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json","lint:fix":"prettier --write '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json","postvalidate:ts":"tsc --noEmit --target es6 test/typescript-validate.ts","prebuild:browser":"mkdirp dist/","pretest":"npm run -s lint","prevalidate:ts":"npm run -s build:ts","start-fixtures-server":"octokit-fixtures-server","test":"nyc mocha test/mocha-node-setup.js \"test/*/**/*-test.js\"","test:browser":"cypress run --browser chrome","update-endpoints":"npm-run-all update-endpoints:*","update-endpoints:fetch-json":"node scripts/update-endpoints/fetch-json","update-endpoints:typescript":"node scripts/update-endpoints/typescript","validate:ts":"tsc --target es6 --noImplicitAny index.d.ts"},"types":"index.d.ts","version":"16.43.1"};
module.exports = {"name":"@octokit/rest","version":"16.43.1","publishConfig":{"access":"public"},"description":"GitHub REST API client for Node.js","keywords":["octokit","github","rest","api-client"],"author":"Gregor Martynus (https://github.com/gr2m)","contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"repository":"https://github.com/octokit/rest.js","dependencies":{"@octokit/auth-token":"^2.4.0","@octokit/plugin-paginate-rest":"^1.1.1","@octokit/plugin-request-log":"^1.0.0","@octokit/plugin-rest-endpoint-methods":"2.4.0","@octokit/request":"^5.2.0","@octokit/request-error":"^1.0.2","atob-lite":"^2.0.0","before-after-hook":"^2.0.0","btoa-lite":"^1.0.0","deprecation":"^2.0.0","lodash.get":"^4.4.2","lodash.set":"^4.3.2","lodash.uniq":"^4.5.0","octokit-pagination-methods":"^1.1.0","once":"^1.4.0","universal-user-agent":"^4.0.0"},"devDependencies":{"@gimenete/type-writer":"^0.1.3","@octokit/auth":"^1.1.1","@octokit/fixtures-server":"^5.0.6","@octokit/graphql":"^4.2.0","@types/node":"^13.1.0","bundlesize":"^0.18.0","chai":"^4.1.2","compression-webpack-plugin":"^3.1.0","cypress":"^3.0.0","glob":"^7.1.2","http-proxy-agent":"^4.0.0","lodash.camelcase":"^4.3.0","lodash.merge":"^4.6.1","lodash.upperfirst":"^4.3.1","lolex":"^5.1.2","mkdirp":"^1.0.0","mocha":"^7.0.1","mustache":"^4.0.0","nock":"^11.3.3","npm-run-all":"^4.1.2","nyc":"^15.0.0","prettier":"^1.14.2","proxy":"^1.0.0","semantic-release":"^17.0.0","sinon":"^8.0.0","sinon-chai":"^3.0.0","sort-keys":"^4.0.0","string-to-arraybuffer":"^1.0.0","string-to-jsdoc-comment":"^1.0.0","typescript":"^3.3.1","webpack":"^4.0.0","webpack-bundle-analyzer":"^3.0.0","webpack-cli":"^3.0.0"},"types":"index.d.ts","scripts":{"coverage":"nyc report --reporter=html && open coverage/index.html","lint":"prettier --check '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json","lint:fix":"prettier --write '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json","pretest":"npm run -s lint","test":"nyc mocha test/mocha-node-setup.js \"test/*/**/*-test.js\"","test:browser":"cypress run --browser chrome","build":"npm-run-all build:*","build:ts":"npm run -s update-endpoints:typescript","prebuild:browser":"mkdirp dist/","build:browser":"npm-run-all build:browser:*","build:browser:development":"webpack --mode development --entry . --output-library=Octokit --output=./dist/octokit-rest.js --profile --json > dist/bundle-stats.json","build:browser:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=Octokit --output-path=./dist --output-filename=octokit-rest.min.js --devtool source-map","generate-bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","update-endpoints":"npm-run-all update-endpoints:*","update-endpoints:fetch-json":"node scripts/update-endpoints/fetch-json","update-endpoints:typescript":"node scripts/update-endpoints/typescript","prevalidate:ts":"npm run -s build:ts","validate:ts":"tsc --target es6 --noImplicitAny index.d.ts","postvalidate:ts":"tsc --noEmit --target es6 test/typescript-validate.ts","start-fixtures-server":"octokit-fixtures-server"},"license":"MIT","files":["index.js","index.d.ts","lib","plugins"],"nyc":{"ignore":["test"]},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"bundlesize":[{"path":"./dist/octokit-rest.min.js.gz","maxSize":"33 kB"}]};

/***/ }),

Expand Down Expand Up @@ -8766,7 +8768,7 @@ function createBuild(params) {
exports.createBuild = createBuild;
function deployBuild(deployConfig) {
return __awaiter(this, void 0, void 0, function* () {
const { accessToken, buildFolder, deployBranch } = deployConfig;
const { accessToken, buildFolder, deployBranch, deployFolder } = deployConfig;
if (!accessToken) {
throw Error('Github Access token not provided. Please add it to your workflow yml');
}
Expand All @@ -8779,6 +8781,7 @@ function deployBuild(deployConfig) {
accessToken,
branch: deployBranch ? deployBranch : 'gh-pages',
folder: buildFolder ? buildFolder : './dist',
targetFolder: deployFolder ? deployFolder : './',
workspace: './'
});
helpers_1.writeToConsole('Deployed build successfully! 🎉🎉🎉');
Expand Down
4 changes: 3 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export async function deployBuild(deployConfig: {
accessToken: string
buildFolder: string
deployBranch: string
deployFolder: string
}): Promise<string> {
const {accessToken, buildFolder, deployBranch} = deployConfig
const {accessToken, buildFolder, deployBranch, deployFolder} = deployConfig
if (!accessToken) {
throw Error(
'Github Access token not provided. Please add it to your workflow yml'
Expand All @@ -56,6 +57,7 @@ export async function deployBuild(deployConfig: {
accessToken,
branch: deployBranch ? deployBranch : 'gh-pages',
folder: buildFolder ? buildFolder : './dist',
targetFolder: deployFolder ? deployFolder : './',
workspace: './'
})
writeToConsole('Deployed build successfully! 🎉🎉🎉')
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async function run(): Promise<void> {
const shouldRunLint = getInput('run_lint')
const accessToken = getInput('github_access_token')
const buildFolder = getInput('angular_dist_build_folder')
const deployFolder = getInput('deploy_folder')
const angularProjectDir = getInput('angular_project_dir')
const deployBranch = getInput('deploy_branch')

Expand Down Expand Up @@ -42,7 +43,8 @@ async function run(): Promise<void> {
await commands.deployBuild({
accessToken,
buildFolder,
deployBranch
deployBranch,
deployFolder
})
} catch (error) {
const skipFailure = getInput('skip_failure')
Expand Down