FIREBASE_TOKEN在CI/CD GitLab中已不建议使用。

huangapple go评论81阅读模式
英文:

FIREBASE_TOKEN deprecated in CI/CD gitlab

问题

我在部署我的Web应用时遇到了一个警告,Firebase告诉我令牌即将被弃用,建议使用Google凭据。

有关如何设置GitLab管道以使用Google凭据的建议吗?我没有找到相关指南。这是我的脚本。

目前,我已配置了一个包含令牌的GitLab环境变量,它能够工作(但会出现警告)。

我尝试在GitLab设置中设置了GOOGLE_APPLICATION_CREDENTIALS环境变量,但我不知道用于部署的Firebase命令是什么。

英文:

I encountered a warning while deploying my web app, firebase tells me that the token is about to be deprecated and I recommend using google credentials.

cicd output

Do you have any advice on how to setup the gitlab pipeline to use google credentials? I have not found a guide on this. This is my script.

gitlab script

At the moment I have configured a gitlab environment variable containing the token and it works (with warning).

gitlab firebase token

I tried setting the GOOGLE_APPLICATION_CREDENTIALS environment variable in gitlab settings but I don't know the firebase command to use to deploy.

答案1

得分: 1

I found the way to deploy from gitlab using the GOOGLE_APPLICATION_CREDENTIALS.
This is my script:

image: node:14.18.0-alpine

before_script:
  - npm i -g firebase-tools
  - echo $FIARD_PRIVATE_KEY > "/private-key.json"
  - export GOOGLE_APPLICATION_CREDENTIALS="/private-key.json"

stages:
  - staging
  - production

deploy_staging:
  stage: staging
  when: manual
  script:
    - firebase use staging
    - firebase deploy --only hosting:ineffe-business-site-staging
    - echo "Deploying hosting staging finished!"
  only:
    - master
  environment:
    name: staging
    url: https://staging-business-ineffe.firebaseapp.com/

deploy_production:
  stage: production
  when: manual
  script:
    - firebase use default
    - firebase deploy --only hosting:ineffe-business-site-prod
    - echo "Deploying hosting production finished!"
  only:
    - master
  environment:
    name: production
    url: https://business-ineffe-com.firebaseapp.com/

I created the environment variable on gitlab based on the environment (staging and production) and it works.
The variables contain the authentication json provided by Google.

gitlab env variables

I posted this answer if it can be useful to someone.

英文:

I found the way to deploy from gitlab using the GOOGLE_APPLICATION_CREDENTIALS.
This is my script:

image: node:14.18.0-alpine

before_script:
  - npm i -g firebase-tools
  - echo $FIARD_PRIVATE_KEY > "/private-key.json"
  - export GOOGLE_APPLICATION_CREDENTIALS="/private-key.json"

stages:
  - staging
  - production

deploy_staging:
  stage: staging
  when: manual
  script:
    - firebase use staging
    - firebase deploy --only hosting:ineffe-business-site-staging
    - echo "Deploying hosting staging finished!"
  only:
    - master
  environment:
    name: staging
    url: https://staging-business-ineffe.firebaseapp.com/

deploy_production:
  stage: production
  when: manual
  script:
    - firebase use default
    - firebase deploy --only hosting:ineffe-business-site-prod
    - echo "Deploying hosting production finished!"
  only:
    - master
  environment:
    name: production
    url: https://business-ineffe-com.firebaseapp.com/

I created the environment variable on gitlab based on the environment (staging and production) and it works.
The variables contain the authentication json provided by Google.

gitlab env variables

I posted this answer if it can be useful to someone.

huangapple
  • 本文由 发表于 2023年3月7日 01:26:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75653962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定