Created
March 26, 2023 05:05
-
-
Save DennisAlund/2606d1e7210ac0db403d5c684dc3c89b to your computer and use it in GitHub Desktop.
Developing with Firebase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deploy the project only on push. | |
- name: Deploy to Firebase | |
if: github.event_name == 'push' | |
# Only deploy hosting here... functions etc are deployed separately | |
run: >- | |
firebase | |
deploy | |
--only hosting | |
-m "Github action run $GITHUB_RUN_ID" | |
--non-interactive | |
--force | |
- name: Set up preview channel | |
if: github.event_name == 'pull_request' | |
# Deploying to preview channel using the branch name as channel name | |
# String split '/' and use the last part of the branch name | |
run: | | |
echo "CHANNEL_NAME=$(echo ${{ github.head_ref }} | grep -o '[^/]*$')" >> $GITHUB_ENV | |
echo "CHANNEL_LIFESPAN=3d" >> $GITHUB_ENV | |
- name: Deploy preview channel to Firebase | |
if: github.event_name == 'pull_request' | |
run: >- | |
firebase | |
hosting:channel:deploy | |
${{ env.CHANNEL_NAME }} | |
--expires ${{ env.CHANNEL_LIFESPAN }} | |
- name: Get preview URL | |
if: github.event_name == 'pull_request' | |
run: | | |
echo "PREVIEW_URL=$(firebase hosting:channel:list | grep ${{ env.CHANNEL_NAME }} | grep -o 'https.*\.app')" >> $GITHUB_ENV | |
- name: Post preview channel URL as a PR comments | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message-id: ${{ matrix.project }} | |
allow-repeats: false | |
message: | | |
Preview the `${{ matrix.project }}` app for ${{ env.CHANNEL_LIFESPAN }}: ${{ env.PREVIEW_URL }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment