diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..77af054 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,29 @@ +on: + workflow_call: + inputs: + environment: + required: true + type: string + description: 'The environment to deploy to' + +jobs: + deploy: + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + + - run: yarn install + - run: npx nx run website:build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} + channelId: live + projectId: ${{ secrets.FIREBASE_PROJECT_ID }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37f0f54..8df74a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ concurrency: permissions: actions: read contents: read + checks: write + pull-requests: write jobs: test: @@ -54,3 +56,19 @@ jobs: path: | .nx key: ${{ steps.nx-cache-restore.outputs.cache-primary-key }} + + deploy-preview: + if: github.ref == 'refs/heads/develop' + needs: test + uses: ./.github/workflows/cd.yml + secrets: inherit + with: + environment: staging + + deploy: + if: github.ref == 'refs/heads/master' + needs: test + uses: ./.github/workflows/cd.yml + secrets: inherit + with: + environment: production diff --git a/.gitignore b/.gitignore index 43a37dc..695b983 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ Thumbs.db .nx/workspace-data .angular .env +.firebaserc diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..1242ff0 --- /dev/null +++ b/firebase.json @@ -0,0 +1,16 @@ +{ + "hosting": { + "public": "dist/apps/website/browser", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} diff --git a/libs/blog/feature-article/src/lib/blog-article.component.spec.ts b/libs/blog/feature-article/src/lib/blog-article.component.spec.ts index a9746cf..f658f6d 100644 --- a/libs/blog/feature-article/src/lib/blog-article.component.spec.ts +++ b/libs/blog/feature-article/src/lib/blog-article.component.spec.ts @@ -1,5 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; + import { BlogArticleComponent } from './blog-article.component'; +import { ArticleService, Article } from '@valerymelou/blog/data-access'; +import { of } from 'rxjs'; describe('BlogArticleComponent', () => { let component: BlogArticleComponent; @@ -8,6 +12,15 @@ describe('BlogArticleComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ imports: [BlogArticleComponent], + providers: [ + provideRouter([]), + { + provide: ArticleService, + useValue: { + getOne: () => of(new Article()), + }, + }, + ], }).compileComponents(); fixture = TestBed.createComponent(BlogArticleComponent); diff --git a/libs/blog/feature-home/src/lib/blog-home.component.spec.ts b/libs/blog/feature-home/src/lib/blog-home.component.spec.ts index f83e407..c88cb99 100644 --- a/libs/blog/feature-home/src/lib/blog-home.component.spec.ts +++ b/libs/blog/feature-home/src/lib/blog-home.component.spec.ts @@ -1,8 +1,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BlogHomeComponent } from './blog-home.component'; -import { Article, ArticleService } from '@valerymelou/blob/data-access'; + import { of } from 'rxjs'; +import { Article, ArticleService } from '@valerymelou/blog/data-access'; + +import { BlogHomeComponent } from './blog-home.component'; + describe('BlogHomeComponent', () => { let component: BlogHomeComponent; let fixture: ComponentFixture;