Update reusable-deploy-pr-preview.yml #24
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 to firebase hosting on PR merge | |
# Specifies deployment target based on branch | |
# Master -> debug | |
# Deployment/{deployment_name} -> {deployment_name} | |
name: Deployment Hosting | |
on: | |
push: | |
branches: | |
- deployment/* | |
- master | |
concurrency: | |
group: deployment-hosting-${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
uses: ./.github/workflows/web-build.yml | |
secrets: inherit | |
with: | |
build-flags: --configuration "production,glitchtip" | |
# use branch name from PR target as default | |
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables | |
deployment: ${{ github.ref }} | |
sourcemaps_upload: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set env | |
run: | | |
echo "APP_VERSION=$(echo "$(cat package.json | jq -r '.version')")" >> $GITHUB_ENV | |
echo "DEPLOYMENT_NAME=${{needs.build.outputs.DEPLOYMENT_NAME}}" >> $GITHUB_ENV | |
echo "GIT_SHA=${{needs.build.outputs.GIT_SHA}}" >> $GITHUB_ENV | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: www | |
- name: Extract Build folder | |
run: | | |
mkdir www | |
tar -xf artifact.tar --directory www | |
- name: Upload sourcemaps | |
run: | | |
npx @sentry/cli releases delete ${DEPLOYMENT_NAME}-${APP_VERSION}-${GIT_SHA} | |
npx @sentry/cli releases files ${DEPLOYMENT_NAME}-${APP_VERSION}-${GIT_SHA} upload-sourcemaps www/ | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN}} | |
SENTRY_URL: https://app.glitchtip.com/ | |
SENTRY_ORG: idems | |
SENTRY_PROJECT: ${{env.DEPLOYMENT_NAME}} | |
continue-on-error: true | |
- name: Store sourcemaps artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: sourcemaps-$GIT_SHA | |
path: www/*.map | |
# Only used for short-term debugging purposes or manual upload | |
retention-days: 30 | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: www | |
- name: Extract Build folder | |
run: | | |
mkdir www | |
tar -xf artifact.tar --directory www | |
- name: Remove sourcemaps from build | |
run: | | |
echo $(ls www) | |
find . -name "*.map" -type f -delete | |
echo $(ls www) | |
### Deploy ### | |
- uses: FirebaseExtended/action-hosting-deploy@v0 | |
with: | |
repoToken: "${{ secrets.GITHUB_TOKEN }}" | |
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_PLH_TEENS_APP1 }}" | |
projectId: plh-teens-app1 | |
# NOTE - deployment target should be set in firebase.json and .firebaserc | |
target: "${{needs.build.outputs.DEPLOYMENT_NAME}}" | |
channelId: live | |
# Known issue - success message does not specify correct deployment url | |
# Not used anywhere else so assume fine for now (only gh action output incorrect) | |
# https://github.com/FirebaseExtended/action-hosting-deploy/issues/126 |