1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【GitHub Actions エラー】CDした時に出たエラーその3 "Error: Cannot deploy a web framework from source because the experiment webframeworks is not enabled. To enable webframeworks run firebase experiments:enable webframeworks"

Last updated at Posted at 2024-12-30

はじめに

GitHub ActionsでFirebaseにデプロイした時の遭遇した複数のエラーについて書いていきます。

前々回の記事はこちら
GitHub ActionsでCDした時に出たエラーその1 "Error: firebase use must be run from a Firebase project directory."

前回の記事はこちら
GitHub ActionsでCDした時に出たエラーその2 "Error: Assertion failed: resolving hosting target of a site with no site name or target name. This should have caused an error earlier"など

問題

このエラーメッセージは、Firebase CLI の webframeworks 実験機能が有効になっていないために発生しているようです。

エラーメッセージ
Error: Cannot deploy a web framework from source because the experiment webframeworks is not enabled. To enable webframeworks run firebase experiments:enable webframeworks
main.yml
name: Scheduled deploy

on:
  push:
  workflow_dispatch:

jobs:
  build:
    name: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Setup Node.js
        uses: actions/setup-node@v2
        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@v2
      - name: Setup Node.js and cache
        uses: actions/setup-node@v2
        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
      - name: change space
        run: ./node_modules/.bin/firebase use ${{ secrets.FIREBASE_PROJECT_ID }}
      - name: Deploy to Firebase Hosting
        env:
          GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/firebase-key.json
        run: |
          ./node_modules/.bin/firebase deploy
      - name: delete GOOGLE_APPLICATION_CREDENTIALS
        run: rm $GOOGLE_APPLICATION_CREDENTIALS
        if: ${{ always() }}

解決方法

Deploy to Firebase Hosting ステップの env セクションに FIREBASE_CLI_EXPERIMENTS: webframeworks を追加しました。
これにより、webframeworks 実験機能が有効になります。
これで、GitHub Actions ワークフロー内で webframeworks 実験機能が有効になり、Firebase にデプロイできるようになります。

main.yml
name: Scheduled deploy

on:
  push:
  workflow_dispatch:

jobs:
  build:
    name: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Setup Node.js
        uses: actions/setup-node@v2
        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@v2
      - name: Setup Node.js and cache
        uses: actions/setup-node@v2
        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
      - name: change space
        run: ./node_modules/.bin/firebase use ${{ secrets.FIREBASE_PROJECT_ID }}
      - name: Deploy to Firebase Hosting
        env:
          GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/firebase-key.json
+         FIREBASE_CLI_EXPERIMENTS: webframeworks
        run: |
          ./node_modules/.bin/firebase deploy
      - name: delete GOOGLE_APPLICATION_CREDENTIALS
        run: rm $GOOGLE_APPLICATION_CREDENTIALS
        if: ${{ always() }}

おわりに

今回、FIREBASE_CLI_EXPERIMENTS: webframeworksを追加して解決しましたが、このコード実は元々書いていたのですが、Firebaseの認証方法として設定していたFIREBASE_TOKENGOOGLE_APPLICATION_CREDENTIALSに修正した際に削除してしまっていたコードでした。
これは、コードを理解せずにやってしまっていた行為であり、次からはコードが分からなければをAIに聞くなどして、理解してから削除なりアクションをしようと思いました。

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?