Skip to content

Commit

Permalink
Reusable Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jixor authored and margni-stephen committed Nov 8, 2023
1 parent ae04da6 commit 13dd048
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 96 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CICD Workflow

on:
push:
branches: [master]
pull_request:
branches: [master]

env:
NODE_ENV: production

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20.x
- run: npm ci
- run: NODE_ENV=test npm run test:coverage
- uses: codecov/codecov-action@v3
- run: npm run build
- uses: actions/upload-artifact@v3
with:
name: build
path: build

preview:
needs: build
if: github.event.pull_request.base.ref == 'master'
uses: ./.github/workflows/deploy.yml
secrets: inherit

end-to-end:
needs: preview
runs-on: ubuntu-latest
env:
NODE_ENV: development
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20.x
- uses: cypress-io/github-action@v6
env:
CYPRESS_BASE_URL: ${{ needs.preview.outputs.details_url }}
- name: Upload Screenshots
if: failure()
uses: actions/upload-artifact@v3
with:
name: cypress-screenshots
path: cypress/screenshots
- if: failure()
name: Upload Videos
uses: actions/upload-artifact@v3
with:
name: cypress-videos
path: cypress/videos

production:
needs: build
if: github.ref == 'refs/heads/master'
uses: ./.github/workflows/deploy.yml
secrets: inherit
with:
channelId: live
31 changes: 31 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy

on:
workflow_call:
inputs:
channelId:
type: string
required: false
outputs:
details_url:
value: ${{ jobs.deploy.outputs.details_url }}

jobs:
deploy:
runs-on: ubuntu-latest
outputs:
details_url: ${{ steps.firebase.outputs.details_url }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: build
path: build
- uses: FirebaseExtended/action-hosting-deploy@v0
id: firebase
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_MARGNI_DOUGH }}'
channelId: ${{ inputs.channelId }}
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
96 changes: 0 additions & 96 deletions .github/workflows/node.js.yml

This file was deleted.

0 comments on commit 13dd048

Please sign in to comment.