diff --git a/.github/workflows/cloudflare_cd.yml b/.github/workflows/cloudflare_cd.yml new file mode 100644 index 0000000..fb172f2 --- /dev/null +++ b/.github/workflows/cloudflare_cd.yml @@ -0,0 +1,53 @@ +name: Deploy Generation Heritage Svelte Kit App to Cloudflare + +on: + workflow_call: + pull_request: + types: [closed] + paths: + - "apps/app**" + +jobs: + ci: + uses: ./.github/workflows/svelte_ci.yml + deploy-to-production: + runs-on: ubuntu-latest + timeout-minutes: 60 + needs: ci + if: github.actor_id == 'vcscsvcscs' || ( github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true ) + steps: + - uses: actions/checkout@v4 + - name: Build & Deploy Worker to Production + uses: cloudflare/wrangler-action@v3 + with: + environment: production + workingDirectory: 'apps/app' + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + secrets: | + GOOGLE_CLIENT_ID + GOOGLE_CLIENT_SECRET + env: + GOOGLE_CLIENT_ID: ${{ secrets.PROD_GOOGLE_CLIENT_ID }} + GOOGLE_CLIENT_SECRET: ${{ secrets.PROD_GOOGLE_CLIENT_SECRET }} + + deploy-to-stage: + runs-on: ubuntu-latest + timeout-minutes: 60 + needs: ci + if: github.actor_id == 'vcscsvcscs' || ( github.ref == 'refs/heads/stage' && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true ) + steps: + - uses: actions/checkout@v4 + - name: Build & Deploy Worker to Stage + uses: cloudflare/wrangler-action@v3 + with: + environment: staging + workingDirectory: 'apps/app' + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + secrets: | + GOOGLE_CLIENT_ID + GOOGLE_CLIENT_SECRET + env: + GOOGLE_CLIENT_ID: ${{ secrets.STAGING_GOOGLE_CLIENT_ID }} + GOOGLE_CLIENT_SECRET: ${{ secrets.STAGING_GOOGLE_CLIENT_SECRET }} \ No newline at end of file diff --git a/.github/workflows/svelte_ci.yml b/.github/workflows/svelte_ci.yml index 0bbf814..67dd738 100644 --- a/.github/workflows/svelte_ci.yml +++ b/.github/workflows/svelte_ci.yml @@ -1,7 +1,9 @@ name: Frontend Continuous Integration on: + workflow_call: pull_request: + types: [opened, synchronize, reopened] paths: - "apps/app**" diff --git a/apps/app/wrangler.jsonc b/apps/app/wrangler.jsonc index 121fb3b..4af443a 100644 --- a/apps/app/wrangler.jsonc +++ b/apps/app/wrangler.jsonc @@ -45,6 +45,9 @@ "staging": { "name": "generations-heritage-stage", "route": "https://ghstage.varghacsongor.hu/*", + "vars": { + "GOOGLE_CALLBACK_URI": "https://ghstage.varghacsongor.hu/login/google/callback" + }, "kv_namespaces": [ { "binding": "GH_SESSIONS", @@ -61,6 +64,9 @@ "production": { "name": "generations-heritage-prod", "route": "https://csalad.varghacsongor.hu/*", + "vars": { + "GOOGLE_CALLBACK_URI": "https://csalad.varghacsongor.hu/login/google/callback" + }, "kv_namespaces": [ { "binding": "GH_SESSIONS",