はじめに
GitHub ActionsでDeploy時に起きたエラー。解決する。
問題
Run ./node_modules/.bin/firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/home/runner/work/sample-vite/sample-vite
Before we get started, keep in mind:
* You are initializing within an existing Firebase project directory
? Which Firebase features do you want to set up for this directory? Press Space
to select features, then Enter to confirm your choices. (Press <space> to
select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
❯◯ Data Connect: Set up a Firebase Data Connect service
◯ Firestore: Configure security rules and indexes files for Firestore
◯ Genkit: Setup a new Genkit project with Firebase
◯ Functions: Configure a Cloud Functions directory and its files
◯ App Hosting: Configure an apphosting.yaml file for App Hosting
◯ Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub
Action deploys
(Move up and down to reveal more choices)
Error: Process completed with exit code 130.
yml記載でfirebase initとしたことが原因。すでに設定したのにも関わらず、deployでするのは違う。
解決方法
ymlを変更する
main
# name: Hello World Workflow
# # トリガー設定: mainブランチへのpush時に実行
# on:
# push:
# branches:
# - main
# jobs:
# hello:
# runs-on: ubuntu-latest # 実行環境
# steps:
# # リポジトリのコードをチェックアウト
# - name: Checkout repository
# uses: actions/checkout@v4
# # Hello World を出力
# - name: Print Hello World
# run: echo "Hello, World!2"
name: Scheduled deploy2
on:
push:
workflow_dispatch:
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install dependencies
run: npm install
- name: Run build
run: npm run build
deploy:
name: deploy
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js and cache
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
- name: Install firebase-tools
run: npm install --save-dev firebase-tools
- name: Decode Firebase service account key
run: |
echo "${{ secrets.FIREBASE_KEY }}" | base64 -d > ./firebase-key.json
echo "GOOGLE_APPLICATION_CREDENTIALS=${{ github.workspace }}/firebase-key.json" >> $GITHUB_ENV
# # Firebaseプロジェクトを初期化
# - name: Initialize Firebase project
# run: ./node_modules/.bin/firebase init
# - name: change space
# run: ./node_modules/.bin/firebase use ${{ secrets.FIREBASE_PROJECT_ID }}
# Firebaseプロジェクトの設定 以下を追加
- name: Set Firebase project
run: ./node_modules/.bin/firebase use --add ${{ secrets.FIREBASE_PROJECT_ID }}
- name: Deploy to Firebase Hosting
run: |
./node_modules/.bin/firebase deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_CLI_EXPERIMENTS: webframeworks
- name: delete GOOGLE_APPLICATION_CREDENTIALS
run: rm $GOOGLE_APPLICATION_CREDENTIALS
if: ${{ always() }}
今度こそうまくいった。
おわりに
完了!