Deploy fatcat app #10
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: Deploy fatcat app | |
on: | |
workflow_dispatch: | |
env: | |
PROJECT_ID: glam-services | |
PROJECT_NUMBER: 178430770772 | |
SERVICE_NAME: glam-fatcat | |
REGION: us-west1 | |
jobs: | |
deploy: | |
name: Deploy to Cloud Run | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Authenticate with Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: projects/${{ env.PROJECT_NUMBER }}/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider | |
service_account: github-actions@${{ env.PROJECT_ID }}.iam.gserviceaccount.com | |
- name: Set up Google Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Configure Docker to use gcloud as a credential helper | |
run: gcloud auth configure-docker $REGION-docker.pkg.dev | |
- name: Prepare .env file | |
env: | |
HELIUS_API_KEY: ${{ secrets.HELIUS_API_KEY }} | |
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} | |
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} | |
DOT_ENV_FILE: apps/fatcat/.env.local | |
run: | | |
echo "NEXT_PUBLIC_SOLANA_RPC=https://mainnet.helius-rpc.com/?api-key=${HELIUS_API_KEY}" > $DOT_ENV_FILE | |
echo "NEXT_PUBLIC_TX_RPC=https://staked.helius-rpc.com/?api-key=${HELIUS_API_KEY}" >> $DOT_ENV_FILE | |
echo "NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL}" >> $DOT_ENV_FILE | |
echo "NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}" >> $DOT_ENV_FILE | |
- name: Build and push Docker image | |
env: | |
DOCKERFILE: apps/fatcat/Dockerfile | |
run: | | |
IMAGE_URI=${REGION}-docker.pkg.dev/${PROJECT_ID}/default/${SERVICE_NAME}:${GITHUB_SHA} | |
docker build -f $DOCKERFILE -t $IMAGE_URI . | |
docker push $IMAGE_URI | |
echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy $SERVICE_NAME \ | |
--image $IMAGE_URI \ | |
--region $REGION \ | |
--allow-unauthenticated | |
gcloud run services update-traffic $SERVICE_NAME --region $REGION --to-latest | |
- name: Send Slack Notification | |
if: success() | |
run: | | |
curl -X POST -H 'Content-type: application/json' --data '{ | |
"text": "✅ *Deployment Successful!* 🚀\n | |
*Service:* `${{ env.SERVICE_NAME }}`\n | |
*Commit:* `${{ github.sha }}`\n | |
*Deployed by:* `${{ github.actor }}`" | |
}' ${{ secrets.SLACK_WEBHOOK_URL_DEPLOY }} |