|
1 | | -name: Deploy Proxy Server to GCP |
| 1 | +name: Deploy Demo |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "demo/**" |
| 8 | + - "!**.md" |
4 | 9 | workflow_dispatch: |
5 | | - inputs: |
6 | | - deploy_env: |
7 | | - description: 'Environment label (optional)' |
8 | | - required: false |
9 | 10 |
|
10 | | -env: |
11 | | - PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} |
12 | | - REGION: ${{ vars.GCP_REGION }} |
13 | | - SERVICE_NAME: ${{ vars.GCP_SERVICE_NAME }} |
14 | | - SUPERDOC_SERVICES_API_KEY: ${{ secrets.SUPERDOC_SERVICES_API_KEY }} |
15 | | - SUPERDOC_SERVICES_BASE_URL: ${{ vars.SUPERDOC_SERVICES_BASE_URL }} |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + pages: write |
| 14 | + id-token: write |
16 | 15 |
|
17 | 16 | jobs: |
18 | 17 | deploy: |
19 | 18 | runs-on: ubuntu-latest |
20 | | - permissions: |
21 | | - contents: read |
22 | | - id-token: write |
23 | | - |
| 19 | + environment: |
| 20 | + name: github-pages |
| 21 | + url: ${{ steps.deployment.outputs.page_url }} |
24 | 22 | steps: |
25 | | - - name: Checkout |
26 | | - uses: actions/checkout@v5 |
27 | | - |
28 | | - - name: Auth to Google Cloud |
29 | | - uses: google-github-actions/auth@v2 |
| 23 | + - name: Generate token |
| 24 | + id: generate_token |
| 25 | + uses: actions/create-github-app-token@v2 |
30 | 26 | with: |
31 | | - credentials_json: ${{ secrets.GCP_SA_KEY }} |
| 27 | + app-id: ${{ secrets.APP_ID }} |
| 28 | + private-key: ${{ secrets.APP_PRIVATE_KEY }} |
32 | 29 |
|
33 | | - - name: Setup gcloud |
34 | | - uses: google-github-actions/setup-gcloud@v2 |
| 30 | + - uses: actions/checkout@v5 |
35 | 31 | with: |
36 | | - project_id: ${{ env.PROJECT_ID }} |
| 32 | + fetch-depth: 0 |
| 33 | + token: ${{ steps.generate_token.outputs.token }} |
37 | 34 |
|
38 | | - - name: Build and push container with Cloud Build |
39 | | - run: | |
40 | | - REGION="${REGION:-us-central1}" |
41 | | - SERVICE_NAME="${SERVICE_NAME:-esign-demo-proxy-server}" |
42 | | - IMAGE="gcr.io/${PROJECT_ID}/${SERVICE_NAME}:${GITHUB_SHA}" |
| 35 | + - uses: pnpm/action-setup@v2 |
| 36 | + with: |
| 37 | + version: 9 |
43 | 38 |
|
44 | | - echo "REGION=${REGION}" >> $GITHUB_ENV |
45 | | - echo "SERVICE_NAME=${SERVICE_NAME}" >> $GITHUB_ENV |
46 | | - echo "IMAGE=${IMAGE}" >> $GITHUB_ENV |
| 39 | + - uses: actions/setup-node@v3 |
| 40 | + with: |
| 41 | + node-version: 20 |
| 42 | + cache: "pnpm" |
47 | 43 |
|
48 | | - gcloud builds submit demo/server --tag "${IMAGE}" |
| 44 | + - name: Install and Build |
49 | 45 | env: |
50 | | - PROJECT_ID: ${{ env.PROJECT_ID }} |
51 | | - REGION: ${{ env.REGION }} |
52 | | - SERVICE_NAME: ${{ env.SERVICE_NAME }} |
53 | | - |
54 | | - - name: Deploy container to Cloud Run |
| 46 | + VITE_SUPERDOC_SERVICES_API_KEY: ${{ secrets.VITE_SUPERDOC_SERVICES_API_KEY }} |
55 | 47 | run: | |
56 | | - REGION="${REGION:-us-central1}" |
57 | | - SERVICE_NAME="${SERVICE_NAME:-esign-demo-proxy-server}" |
58 | | - IMAGE="${IMAGE}" |
59 | | - SUPERDOC_SERVICES_BASE_URL="${SUPERDOC_SERVICES_BASE_URL:-https://api.superdoc.dev}" |
| 48 | + pnpm install |
| 49 | + rm -rf dist |
| 50 | + pnpm build |
| 51 | + cd demo |
| 52 | + rm -rf node_modules dist |
| 53 | + pnpm install |
| 54 | + pnpm build |
| 55 | +
|
| 56 | + - name: Upload artifact |
| 57 | + uses: actions/upload-pages-artifact@v4 |
| 58 | + with: |
| 59 | + path: ./demo/dist |
60 | 60 |
|
61 | | - gcloud run deploy "${SERVICE_NAME}" \ |
62 | | - --image "${IMAGE}" \ |
63 | | - --region "${REGION}" \ |
64 | | - --memory=1Gi \ |
65 | | - --cpu=1 \ |
66 | | - --allow-unauthenticated \ |
67 | | - --set-env-vars SUPERDOC_SERVICES_BASE_URL="${SUPERDOC_SERVICES_BASE_URL}" \ |
68 | | - --set-secrets="SUPERDOC_SERVICES_API_KEY=esign-demo-sd-services-api-key:latest" |
69 | | - env: |
70 | | - IMAGE: ${{ env.IMAGE }} |
71 | | - REGION: ${{ env.REGION }} |
72 | | - SERVICE_NAME: ${{ env.SERVICE_NAME }} |
73 | | - SUPERDOC_SERVICES_API_KEY: ${{ env.SUPERDOC_SERVICES_API_KEY }} |
74 | | - SUPERDOC_SERVICES_BASE_URL: ${{ env.SUPERDOC_SERVICES_BASE_URL }} |
| 61 | + - name: Deploy to GitHub Pages |
| 62 | + id: deployment |
| 63 | + uses: actions/deploy-pages@v4 |
0 commit comments