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: setup deploy previews #227

Merged
merged 5 commits into from
Jul 14, 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
31 changes: 27 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
VM_CONTENTFUL_SPACE: ${{ secrets.VM_CONTENTFUL_SPACE }}
VM_CONTENTFUL_ACCESS_TOKEN: ${{ secrets.VM_CONTENTFUL_ACCESS_TOKEN }}
VM_CONTENTFUL_ENVIRONMENT: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }}
outputs:
ENVIRONMENT: ${{ env.VM_CONTENTFUL_ENVIRONMENT }}
steps:
- uses: actions/checkout@v4

Expand All @@ -24,10 +26,31 @@ jobs:
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: build-output-${{ github.ref_name }}
name: build-output-${{ env.VM_CONTENTFUL_ENVIRONMENT }}
path: |
dist

preview:
if: ${{ github.event.pull_request.base.ref == 'develop' }}
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v4

- name: Download build result
uses: actions/download-artifact@v4
with:
path: dist
name: build-output-${{ needs.build.outputs.ENVIRONMENT }}

- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
channelId: preview
projectId: ${{ secrets.FIREBASE_PROJECT_ID }}

staging:
if: github.ref == 'refs/heads/develop'
needs: build
Expand All @@ -40,13 +63,13 @@ jobs:
uses: actions/download-artifact@v4
with:
path: dist
name: build-output-${{ github.ref_name }}
name: build-output-${{ needs.build.outputs.ENVIRONMENT }}

- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
channelId: preview
channelId: live
projectId: ${{ secrets.FIREBASE_PROJECT_ID }}

production:
Expand All @@ -61,7 +84,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: dist
name: build-output-${{ github.ref_name }}
name: build-output-${{ needs.build.outputs.ENVIRONMENT }}

- uses: FirebaseExtended/action-hosting-deploy@v0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
key: ${{ steps.nx-cache-restore.outputs.cache-primary-key }}

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