Fix firebase command #4
This file contains hidden or 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
name: Configure Firebase Secrets with Matrix | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
actions: read | |
contents: read | |
jobs: | |
firebase_secrets_update: | |
name: Update Firebase Secrets | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
config: | |
- variable: "NEXT_PUBLIC_FIREBASE_API_KEY" | |
secret: "firebaseApiKey" | |
- variable: "NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN" | |
secret: "firebaseAuthDomain" | |
- variable: "NEXT_PUBLIC_FIREBASE_DATABASE_URL" | |
secret: "firebaseDatabaseUrl" | |
- variable: "NEXT_PUBLIC_FIREBASE_PROJECT_ID" | |
secret: "firebaseProjectId" | |
- variable: "NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET" | |
secret: "firebaseStorageBucket" | |
- variable: "NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID" | |
secret: "firebaseMessagingSenderId" | |
- variable: "NEXT_PUBLIC_FIREBASE_APP_ID" | |
secret: "firebaseAppId" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
- run: npm ci --legacy-peer-deps | |
- name: Load environment variable value | |
id: load_env | |
run: | | |
echo "${{ secrets.APP_CMS_DOT_ENV }}" > apps/cms/.env | |
value=$(grep -m 1 "${{ matrix.config.variable }}" apps/cms/.env | cut -d '=' -f 2 || true) | |
if [ -z "$value" ]; then | |
echo "Environment variable ${{ matrix.config.variable }} is missing in the .env file!" | |
exit 1 | |
fi | |
echo "CONFIG_VALUE=$value" >> $GITHUB_ENV | |
shell: bash | |
- name: Save config value to a file | |
run: | | |
touch ${{ matrix.config.variable }} | |
echo "${{ env.CONFIG_VALUE }}" > ${{ matrix.config.variable }} | |
- name: Set secret value in Firebase | |
uses: w9jds/firebase-action@master | |
with: | |
args: apphosting:secrets:set --force --data-file ${{ matrix.config.variable }} ${{ matrix.config.secret }} | |
env: | |
GCP_SA_KEY: ${{ secrets.FIREBASE_DEPLOY_SA }} | |
- name: Grant access to the secret | |
uses: w9jds/firebase-action@master | |
with: | |
args: apphosting:secrets:grantaccess ${{ matrix.config.secret }} | |
env: | |
GCP_SA_KEY: ${{ secrets.FIREBASE_DEPLOY_SA }} | |
- name: Clean up | |
if: always() | |
run: | | |
rm ${{ matrix.config.variable }} | |
rm apps/cms/.env |