-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (95 loc) · 3.47 KB
/
Copy pathfirebase-web-cd.yml
File metadata and controls
99 lines (95 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Build and Deploy Web app to Firebase hosting
# Workflow version: 6.0.0
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
on:
workflow_call:
inputs:
firebase_service_account_override:
description: "Optional Firebase Service Account Key Override"
required: false
type: string
use_preview_channel:
description: "Deploy to preview channel or live channel"
required: false
type: boolean
default: false
subfolder:
type: string
description: "Subfolder where the Flutter project is located"
required: false
default: "."
target:
type: string
description: "Optional target string for action-hosting-deploy"
required: false
additional_commands:
type: string
description: "Additional commands to be run after flutter pub get"
required: false
default: ""
dotenv_override:
description: "Optional dotenv Override"
required: false
type: string
flutter_version:
description: "Optional Flutter Version"
required: false
type: string
env:
PROJECT_ID: ${{ vars.PROJECT_ID }}
FIREBASE_SERVICE_ACCOUNT: ${{ secrets[inputs.firebase_service_account_override || 'FIREBASE_SERVICE_ACCOUNT'] }} # Use the override if provided
DOTENV_BASE64: ${{ secrets[inputs.dotenv_override || 'DOTENV_BASE64'] }}
jobs:
build:
defaults:
run:
working-directory: ${{ inputs.subfolder }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Flutter install specific version
if: inputs.flutter_version != ''
uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
cache-key: ${{ runner.OS }}-flutter-install-cache
flutter-version: ${{ inputs.flutter_version }}
- name: Flutter install stable version
if: inputs.flutter_version == ''
uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
cache-key: ${{ runner.OS }}-flutter-install-cache
- name: Create dotenv file from GitHub Secrets
env:
DOTENV_BASE64: ${{ env.DOTENV_BASE64 }}
run: echo -n "${DOTENV_BASE64}" | base64 -d > dotenv
- name: Run additional commands
if: inputs.additional_commands != ''
run: |
${{ inputs.additional_commands }}
shell: bash
- name: Build Flutter Web App
run: |
flutter pub get
flutter build web --release --no-tree-shake-icons
- name: Determine channel name
id: channel_name
run: echo "CHANNEL_NAME=$(echo "${{ github.event.pull_request.title || github.run_id }}" | sed -e "s/'/\\\'/g; s/[^a-zA-Z0-9]/-/g")" >> $GITHUB_ENV
- name: Set Deploy Command
id: deploy-command
run: echo "DEPLOY_COMMAND=$(if ${{ inputs.use_preview_channel }}; then echo \"${CHANNEL_NAME}\"; else echo 'live'; fi)" >> $GITHUB_ENV
env:
CHANNEL_NAME: ${{ env.CHANNEL_NAME }}
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ env.FIREBASE_SERVICE_ACCOUNT }}"
projectId: "${{ env.PROJECT_ID }}"
channelId: "${{ env.DEPLOY_COMMAND }}"
target: "${{ inputs.target }}"
expires: 3d
entryPoint: "${{ inputs.subfolder }}"