Create README.md #25
This file contains 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: Firebase Deploy to GCP | |
on: | |
push: | |
branches: [prod] | |
pull_request: | |
branches: [prod] | |
jobs: | |
deploy: | |
permissions: | |
contents: "read" | |
id-token: "write" | |
environment: prod | |
name: Setup Gcloud Account | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- id: auth | |
name: Login | |
uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER_ID }} | |
service_account: ${{ secrets.WIP_EMAIL }} | |
- name: Configure gcloud | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
- name: create env file | |
run: | | |
cd functions | |
touch .env | |
echo "DISCORD_SERVER_ID=${{ secrets.DISCORD_SERVER_ID }}" >> .env | |
echo "DISCORD_CHANNEL_ID=${{ secrets.DISCORD_CHANNEL_ID }}" >> .env | |
echo "DISCORD_SALAI_TOKEN=${{ secrets.DISCORD_SALAI_TOKEN }}" >> .env | |
- name: Use NPM to install dependencies | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "18.x" | |
- run: | | |
cd functions | |
npm install | |
- name: Build | |
run: | | |
cd functions | |
npm run build | |
- name: deploy | |
uses: "google-github-actions/deploy-cloud-functions@@v2" | |
with: | |
# Name of the Cloud Function, same as the entry point name | |
name: "onGenerationCreated" | |
source_dir: "functions" | |
# Runtime to use for the function | |
runtime: "nodejs18" | |
event_trigger_type: 'providers/cloud.firestore/eventTypes/document.create' | |
event_trigger_resource: 'projects/${{ secrets.GCP_PROJECT_ID }}/databases/(default)/documents/users/{userId}/locations/{locationId}/generations/{generationId}' |