Skip to content

Commit

Permalink
fix: update the deploy.yml and build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Jan 4, 2025
1 parent 624bf22 commit ae6bd0e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 28 deletions.
40 changes: 14 additions & 26 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,18 @@ jobs:
steps:
- name: Update environment secrets in Cloudflare
run: |
REPOSITORY_NAME=${{ github.repository }}
REPOSITORY_NAME=${REPOSITORY_NAME//./-}
curl -X PUT \
"https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/" + ${REPOSITORY_NAME} + "/deployment_configs" \
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \
-H "Content-Type: application/json" \
--data '{
"deployment_configs": {
"production": {
"env_vars": {
"VOYAGE_API_KEY": {
"value": "${{ secrets.VOYAGEAI_API_KEY }}",
"type": "secret_text"
},
"SUPABASE_URL": {
"value": "${{ secrets.SUPABASE_URL }}",
"type": "secret_text"
},
"SUPABASE_ANON_KEY": {
"value": "${{ secrets.SUPABASE_ANON_KEY }}",
"type": "secret_text"
}
}
}
}
}'
- name: Checkout repository
uses: actions/checkout@v4
- name: Make script executable
run: chmod +x .github/workflows/sync-enn-vars.sh
- name: Run sync environment variables script
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
VOYAGEAI_API_KEY: ${{ secrets.VOYAGEAI_API_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: .github/workflows/sync-env-vars.sh
38 changes: 38 additions & 0 deletions .github/workflows/sync-env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Check if required environment variables are set
if [ -z "$CLOUDFLARE_ACCOUNT_ID" ] || [ -z "$CLOUDFLARE_API_TOKEN" ] || [ -z "$GITHUB_REPOSITORY" ] || \
[ -z "$VOYAGEAI_API_KEY" ] || [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_ANON_KEY" ]; then
echo "Error: Required environment variables are not set"
exit 1
fi

# Convert repository name format
REPOSITORY_NAME=$GITHUB_REPOSITORY
REPOSITORY_NAME=${REPOSITORY_NAME//./-}

# Make the API call to Cloudflare
curl -X PUT \
"https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects/${REPOSITORY_NAME}/deployment_configs" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{
"deployment_configs": {
"production": {
"env_vars": {
"VOYAGE_API_KEY": {
"value": "'"${VOYAGEAI_API_KEY}"'",
"type": "secret_text"
},
"SUPABASE_URL": {
"value": "'"${SUPABASE_URL}"'",
"type": "secret_text"
},
"SUPABASE_ANON_KEY": {
"value": "'"${SUPABASE_ANON_KEY}"'",
"type": "secret_text"
}
}
}
}
}'
3 changes: 1 addition & 2 deletions functions/issue-scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const corsHeaders = {
"Access-Control-Allow-Headers": "Content-Type",
};


export async function onRequest(ctx: Context): Promise<Response> {
const { request, env } = ctx;
const url = new URL(request.url);
Expand All @@ -16,7 +15,7 @@ export async function onRequest(ctx: Context): Promise<Response> {
case "GET":
if (url.searchParams.has("key")) {
const key = url.searchParams.get("key") as string;
return new Response("GET request with key: " + key + JSON.stringify(env), {
return new Response("GET request with key: " + key + JSON.stringify(env.SUPABASE_ANON_KEY), {
headers: corsHeaders,
status: 200,
});
Expand Down

0 comments on commit ae6bd0e

Please sign in to comment.