我一直在尝试使用 Github actions CI/CD 工作流程自动部署 firebase 云功能。这些函数是使用 NodeJs、Express 和 Typescript 开发的。所有环境变量都保存在 .env 文件中,该文件未在 github 上跟踪(出于显而易见的原因)
main.yaml 文件(在 .github/workflows/ 中)
name: CI/CD
on:
push:
branches: [ deploy ]
pull_request:
branches: [ deploy ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: create env file
run: |
cd functions
touch .env
echo "${{ secrets.ENV_VARS }}" >> .env
- name: Install npm packages
run: |
cd functions
npm install
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy
env: …Run Code Online (Sandbox Code Playgroud) environment-variables google-cloud-functions env-file github-actions cicd