Skip to content

Commit e3e8b92

Browse files
Feature/deploy GitHub workflow (#6)
* Added base href * added deploy script * added ng deploy * Added user details for deployment * forgot closing brace * Added initial card for mock api module * Fixed tests
1 parent b15a43b commit e3e8b92

File tree

13 files changed

+239
-70
lines changed

13 files changed

+239
-70
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,9 @@ jobs:
2929
with:
3030
node-version: ${{ matrix.node-version }}
3131

32-
- name: Install and Build
32+
- name: Install and Deploy
33+
env:
34+
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
3335
run: |
3436
npm install
3537
npm run deploy:github-pages
36-
37-
- name: Deploy 🚀
38-
uses: JamesIves/github-pages-deploy-action@releases/v3
39-
with:
40-
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
41-
BRANCH: gh-pages # The branch the action should deploy to.
42-
FOLDER: dist/angular-component-library # The folder the action should deploy.

angular.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
"polyfills": "src/polyfills.ts",
2424
"tsConfig": "tsconfig.app.json",
2525
"aot": true,
26-
"assets": ["src/favicon.ico", "src/assets"],
26+
"assets": [
27+
"src/favicon.ico",
28+
"src/assets"
29+
],
2730
"styles": [
2831
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
2932
"src/styles.scss"
@@ -96,7 +99,10 @@
9699
"polyfills": "src/polyfills.ts",
97100
"tsConfig": "tsconfig.spec.json",
98101
"karmaConfig": "karma.conf.js",
99-
"assets": ["src/favicon.ico", "src/assets"],
102+
"assets": [
103+
"src/favicon.ico",
104+
"src/assets"
105+
],
100106
"styles": [
101107
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
102108
"src/styles.scss"
@@ -112,7 +118,9 @@
112118
"tsconfig.spec.json",
113119
"e2e/tsconfig.json"
114120
],
115-
"exclude": ["**/node_modules/**"]
121+
"exclude": [
122+
"**/node_modules/**"
123+
]
116124
}
117125
},
118126
"e2e": {
@@ -126,9 +134,13 @@
126134
"devServerTarget": "angular-component-library:serve:production"
127135
}
128136
}
137+
},
138+
"deploy": {
139+
"builder": "angular-cli-ghpages:deploy",
140+
"options": {}
129141
}
130142
}
131143
}
132144
},
133145
"defaultProject": "angular-component-library"
134-
}
146+
}

package-lock.json

Lines changed: 157 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"lint": "ng lint",
1717
"e2e": "ng e2e",
1818
"build:ci": "npm run clean && npm run test && npm run build:prod",
19-
"deploy:github-pages": "ng build --prod --base-href 'https://chapi-chapi.github.io/angular-component-library/'",
19+
"deploy:github-pages": "ng deploy --base-href=/angular-component-library/ --name=\"rogue-elephant\" [email protected]",
2020
"start:proxy:mock:server": "concurrently --kill-others \"npm run mock:server\" \"npm run start:proxy\"",
2121
"package:mock-api": "ng-packagr -p ./src/app/shared/interceptors/mock-api/package.json",
2222
"package:publish:mock-api": "npm publish ./dist/packages/@chapichapi/mock-api --access public"
@@ -48,6 +48,7 @@
4848
"@types/jasmine": "~3.5.0",
4949
"@types/jasminewd2": "~2.0.3",
5050
"@types/node": "^12.11.1",
51+
"angular-cli-ghpages": "^0.6.2",
5152
"codelyzer": "^5.1.2",
5253
"concurrently": "^5.1.0",
5354
"jasmine-core": "~3.5.0",

src/app/app-routing.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
3-
import { ProductsComponent } from './pages/components/components.component';
3+
import { ComponentsComponent } from './pages/components/components.component';
44

55

66
const routes: Routes = [
77
{
88
path: 'components',
9-
component: ProductsComponent
9+
component: ComponentsComponent
1010
},
1111
{ path: '',
1212
redirectTo: '/components',

src/app/app.module.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { NgModule } from "@angular/core";
44
import { AppRoutingModule } from "./app-routing.module";
55
import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http";
66
import { AppComponent } from "./app.component";
7-
import { ProductsComponent } from "./pages/components/components.component";
7+
import { ComponentsComponent } from "./pages/components/components.component";
88
import { RouterModule } from "@angular/router";
99
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
1010
import { FlexLayoutModule } from "@angular/flex-layout";
@@ -38,12 +38,13 @@ import { environment } from 'src/environments/environment';
3838

3939
const mockApi : IMockInterceptorData[] = [
4040
{
41-
url: "/api/products",
41+
url: "/api/components",
4242
httpVerb: "GET",
4343
data: [
4444
{
45-
name: "Product A",
46-
description: "Some new product",
45+
name: "Mock Api",
46+
subtitle: "Interceptor",
47+
description: "Provides an interceptor for mocking API calls.",
4748
insertedUtc: new Date(),
4849
updatedUtc: new Date(),
4950
},
@@ -54,7 +55,7 @@ const mockApi : IMockInterceptorData[] = [
5455
@NgModule({
5556
declarations: [
5657
AppComponent,
57-
ProductsComponent,
58+
ComponentsComponent,
5859
LoaderComponent,
5960
],
6061
imports: [
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<h1>Components</h1>
2+
<h3>Below is a list of available components</h3>
23

34
<chapichapi-card-list
4-
[cards$]="products$"
5+
[cards$]="components$"
56
[itemDetailsLink]="'/update-product'"
67
></chapichapi-card-list>

src/app/pages/components/components.component.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22

3-
import { ProductsComponent } from './components.component';
3+
import { ComponentsComponent } from './components.component';
44
import { ApiService } from '../../shared/services/api.service';
55
import { HttpClientModule, HttpClient } from '@angular/common/http';
66
import { RouterTestingModule } from '@angular/router/testing';
77

8-
describe('ProductsComponent', () => {
9-
let component: ProductsComponent;
10-
let fixture: ComponentFixture<ProductsComponent>;
8+
describe('ComponentsComponent', () => {
9+
let component: ComponentsComponent;
10+
let fixture: ComponentFixture<ComponentsComponent>;
1111

1212
beforeEach(async(() => {
1313
TestBed.configureTestingModule({
14-
declarations: [ ProductsComponent ],
14+
declarations: [ ComponentsComponent ],
1515
providers: [ApiService, HttpClient],
1616
imports: [HttpClientModule, RouterTestingModule]
1717
})
1818
.compileComponents();
1919
}));
2020

2121
beforeEach(() => {
22-
fixture = TestBed.createComponent(ProductsComponent);
22+
fixture = TestBed.createComponent(ComponentsComponent);
2323
component = fixture.componentInstance;
2424
fixture.detectChanges();
2525
});

0 commit comments

Comments
 (0)