Skip to content

Commit

Permalink
chore: decouple build from deploy in cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
valerymelou committed Jul 13, 2024
1 parent 7e93a92 commit 8971d35
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ on:
workflow_call:

jobs:
staging:
if: github.ref == 'refs/heads/develop'
build:
runs-on: ubuntu-latest
environment: staging
environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'develop' }}
steps:
- uses: actions/checkout@v4

Expand All @@ -17,6 +16,27 @@ jobs:

- run: yarn install
- run: npx nx run website:build

- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
dist
staging:
if: github.ref == 'refs/heads/develop'
needs: build
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4

- name: Download build result
uses: actions/download-artifact@v4
with:
name: build-output

- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -25,20 +45,18 @@ jobs:
projectId: ${{ secrets.FIREBASE_PROJECT_ID }}

production:
if: github.ref == 'refs/heads/develop'
if: github.ref == 'refs/heads/master'
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
- name: Download build result
uses: actions/download-artifact@v4
with:
node-version: 20
cache: 'yarn'
name: build-output

- run: yarn install
- run: npx nx run website:build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 8971d35

Please sign in to comment.