Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: decouple build from deploy in cd.yml #223

Merged
merged 3 commits into from
Jul 13, 2024
Merged
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
40 changes: 30 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,28 @@ jobs:

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

- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: build-output-${{ github.ref_name }}
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:
path: dist
name: build-output-${{ github.ref_name }}

- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -25,20 +46,19 @@ 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'
path: dist
name: build-output-${{ github.ref_name }}

- run: yarn install
- run: npx nx run website:build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
key: ${{ steps.nx-cache-restore.outputs.cache-primary-key }}

deploy:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
needs: test
uses: ./.github/workflows/cd.yml
secrets: inherit