Skip to content

Commit

Permalink
ci: update workflow for use firebase native runners
Browse files Browse the repository at this point in the history
  • Loading branch information
otani88 committed Jun 3, 2024
1 parent d8ab96e commit 25e8361
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 23 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/app-deploy-feature-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: pull_request
jobs:
build:
name: Build and Test App
runs-on: ubuntu-latest
runs-on: matterlabs-firebase-deployer
permissions:
contents: read
pull-requests: write
Expand All @@ -13,7 +13,9 @@ jobs:
run:
working-directory: ./packages/app
outputs:
dappUrl: ${{ steps.deploy.outputs.details_url }}
dappUrl: ${{ steps.check_channel.outputs.channel_url }}
env:
CHANNEL_NAME: ${{ github.head_ref }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -26,6 +28,10 @@ jobs:
node-version: '18'
cache: 'npm'

- name: Install Firebase CLI and auth
run: |
npm install -g firebase-tools
- name: Install dependencies
working-directory: ./
run: |
Expand Down Expand Up @@ -54,15 +60,30 @@ jobs:
run: |
echo "window[\"##runtimeConfig\"] = { appEnvironment: \"staging\" };" > dist/config.js
- name: Check if Firebase Hosting channel exists
working-directory: ./packages/app
id: check_channel
run: |
CHANNEL_URL=$(firebase hosting:channel:list --json | jq --arg channel_name "${CHANNEL_NAME}" -r '.result.channels[]|select(.name|contains($channel_name)) | .url')
if [ -z "$CHANNEL_URL" ]; then
echo "New channel"
firebase hosting:channel:create $CHANNEL_NAME
CHANNEL_URL=$(firebase hosting:channel:list --json | jq --arg channel_name "${CHANNEL_NAME}" -r '.result.channels[]|select(.name|contains($channel_name)) | .url')
fi
echo "channel_url=${CHANNEL_URL}" >> $GITHUB_OUTPUT
- name: Deploy
uses: matter-labs/action-hosting-deploy@main
id: deploy
working-directory: ./packages/app
run: |
firebase hosting:channel:deploy ${{ env.CHANNEL_NAME }}
- name: Publish preview url
uses: thollander/actions-comment-pull-request@v2
with:
repoToken: "${{ github.token }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING_SCAN_V2 }}"
expires: 7d
projectId: staging-scan-v2
entryPoint: ./packages/app
comment_tag: preview_url
message: |
Visit the preview URL for this PR:
${{ steps.check_channel.outputs.channel_url }}
mainnet:
needs: build
Expand Down
41 changes: 29 additions & 12 deletions .github/workflows/app-deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,28 @@ name: Deploy App to Preview
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
runs-on: matterlabs-firebase-deployer
permissions:
contents: read
outputs:
dappUrl: ${{ steps.deploy.outputs.details_url }}
dappUrl: ${{ steps.check_channel.outputs.channel_url }}
env:
CHANNEL_NAME: ${{ github.event.inputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install Firebase CLI and auth
run: |
npm install -g firebase-tools
- name: Download Dist package
uses: dsaltares/fetch-gh-release-asset@master
with:
Expand All @@ -45,21 +56,27 @@ jobs:
run: |
unzip storybook-static.zip -d packages/app
- name: Check if Firebase Hosting channel exists
working-directory: ./packages/app
id: check_channel
run: |
CHANNEL_URL=$(firebase hosting:channel:list --json | jq --arg channel_name "${CHANNEL_NAME}" -r '.result.channels[]|select(.name|contains($channel_name)) | .url')
if [ -z "$CHANNEL_URL" ]; then
echo "New channel"
firebase hosting:channel:create $CHANNEL_NAME
CHANNEL_URL=$(firebase hosting:channel:list --json | jq --arg channel_name "${CHANNEL_NAME}" -r '.result.channels[]|select(.name|contains($channel_name)) | .url')
fi
echo "channel_url=${CHANNEL_URL}" >> $GITHUB_OUTPUT
- name: Deploy
id: deploy
uses: matter-labs/action-hosting-deploy@main
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SCAN_V2 }}'
expires: 7d
projectId: scan-v2
channelID: ${{ github.event.inputs.version }}
entryPoint: ./packages/app
working-directory: ./packages/app
run: |
firebase hosting:channel:deploy ${{ env.CHANNEL_NAME }}
- name: Output version url on success
run: |
run: |
echo "Block explorer app has been deployed to: ${{ steps.deploy.outputs.details_url }}"
echo "Block explorer app has been deployed to: ${{ steps.check_channel.outputs.channel_url }}
mainnet:
needs: deploy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/app-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
- name: Deploy
working-directory: ./packages/app
run: |
firebase hosting:channel:deploy live
firebase deploy
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 18

- name: Install Firebase CLI and auth
run: |
npm install -g firebase-tools
- name: Download Dist package
uses: dsaltares/fetch-gh-release-asset@master
with:
Expand Down Expand Up @@ -188,5 +191,5 @@ jobs:
- name: Deploy
working-directory: ./packages/app
run: |
firebase hosting:channel:deploy live
firebase deploy

0 comments on commit 25e8361

Please sign in to comment.