Skip to content

Revert "Reapply "Reapply "Commit to test new GitHub Action""" #6

Revert "Reapply "Reapply "Commit to test new GitHub Action"""

Revert "Reapply "Reapply "Commit to test new GitHub Action""" #6

name: Build and Deploy Backend
on:
push:
branches:
- main
paths:
- 'backend/**'
- 'frontend/src/shared/**'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Generate version
id: version
run: |
echo "version=dev-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Copy shared code
run: |
mkdir -p backend/src/.shared
cp -r frontend/src/shared/* backend/src/.shared/
- name: Google Auth
id: auth
uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
service_account: ${{ secrets.WIF_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Check for required secrets
run: |

Check failure on line 43 in .github/workflows/backend-deploy.yml

View workflow run for this annotation

GitHub Actions / Build and Deploy Backend

Invalid workflow file

The workflow is not valid. .github/workflows/backend-deploy.yml (Line: 43, Col: 14): Unrecognized named-value: 'secret'. Located at position 9 within expression: secrets[secret]
required_secrets=("OPENAI_API_KEY" "DB_USER" "DB_HOST" "DB_NAME" "DB_PASSWORD" "GOOGLE_CLIENT_ID")
missing_secrets=()
for secret in "${required_secrets[@]}"; do
if [ -z "${{ secrets[secret] }}" ]; then
missing_secrets+=("$secret")
fi
done
if [ ${#missing_secrets[@]} -ne 0 ]; then
echo "Error: The following required secrets are missing:"
for secret in "${missing_secrets[@]}"; do
echo "- $secret"
done
exit 1
fi
echo "All required secrets are present. Proceeding with deployment..."
- name: Build and Push Image
run: |
cd backend
echo "Starting Cloud Build..."
gcloud builds submit --tag gcr.io/mindmeld-backend/mindmeld:${{ steps.version.outputs.version }} --async
echo "Build submitted successfully!"
echo "You can view the build progress at: https://console.cloud.google.com/cloud-build/builds"
- name: Deploy to Cloud Run
run: |
gcloud run deploy mindmeld \
--image gcr.io/mindmeld-backend/mindmeld:${{ steps.version.outputs.version }} \
--add-cloudsql-instances ${{ secrets.CLOUD_SQL_CONNECTION_NAME }} \
--set-secrets=OPENAI_API_KEY=OPENAI_API_KEY:latest,DB_USER=DB_USER:latest,DB_HOST=DB_HOST:latest,DB_NAME=DB_NAME:latest,DB_PASSWORD=DB_PASSWORD:latest,GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID:latest \
--platform managed \
--region europe-west1 \
--allow-unauthenticated