name: Deploy Cloud Function

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Authenticate gcloud
        uses: google-github-actions/auth@v2.1.0
        with:
          credentials_json: ${{ secrets.GCP_SA_KEY }}

      - name: Set up Google Cloud SDK
        uses: google-github-actions/setup-gcloud@v2.1.0
        with:
          version: '479.0.0' # Update with the appropriate version
          project_id: function-fo
          install_components: 'beta' # Install additional components if required
          skip_install: false

      - name: Deploy Cloud Function
        run: |
          gcloud functions deploy ExchangeTokenFunction --runtime nodejs20 --trigger-http --allow-unauthenticated
