diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ed7dd57..2b30679 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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 @@ -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 }} @@ -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 }}