Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions .github/workflows/university-web-redeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Redeploy University Web

on:
workflow_dispatch:
inputs:
reason:
description: "Reason for rebuilding university SSG pages"
required: false
default: "University API data updated"
type: string
repository_dispatch:
types: [university-data-updated]

permissions:
contents: read

concurrency:
group: university-web-production-redeploy
cancel-in-progress: false

jobs:
redeploy:
name: Redeploy university web production
runs-on: ubuntu-latest
timeout-minutes: 20
environment:
name: Production โ€“ solid-connect-university-web
url: ${{ steps.deploy.outputs.deployment_url }}
env:
VERCEL_PROJECT_NAME: solid-connect-university-web
VERCEL_RELEASE_BRANCH: release-university
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
REDEPLOY_REASON: ${{ github.event.inputs.reason || github.event.client_payload.reason || 'University API data updated' }}
steps:
- name: Checkout university release branch
uses: actions/checkout@v4
with:
ref: release-university
fetch-depth: 1

- name: Validate Vercel credentials
run: |
set -euo pipefail

if [ -z "$VERCEL_ORG_ID" ] || [ -z "$VERCEL_TOKEN" ]; then
echo "VERCEL_ORG_ID and VERCEL_TOKEN secrets are required." >&2
exit 1
fi

- name: Trigger fresh production deployment
id: deploy
env:
REPOSITORY_ID: ${{ github.event.repository.id }}
run: |
set -euo pipefail

RELEASE_SHA=$(git rev-parse HEAD)
REQUEST_BODY=$(jq -n \
--arg name "$VERCEL_PROJECT_NAME" \
--arg ref "$VERCEL_RELEASE_BRANCH" \
--arg sha "$RELEASE_SHA" \
--argjson repoId "$REPOSITORY_ID" \
'{
name: $name,
gitSource: {
type: "github",
repoId: $repoId,
ref: $ref,
sha: $sha
},
target: "production"
}')

HTTP_STATUS=$(curl --silent --show-error \
--output deployment.json \
--write-out "%{http_code}" \
--request POST \
--header "Authorization: Bearer $VERCEL_TOKEN" \
--header "Content-Type: application/json" \
--data "$REQUEST_BODY" \
"https://api.vercel.com/v13/deployments?teamId=$VERCEL_ORG_ID&forceNew=1")

if [[ ! "$HTTP_STATUS" =~ ^2 ]]; then
jq -r '.error.message // "Vercel deployment request failed."' deployment.json >&2
exit 1
fi

DEPLOYMENT_ID=$(jq -r '.id // empty' deployment.json)
DEPLOYMENT_HOST=$(jq -r '.url // empty' deployment.json)

if [ -z "$DEPLOYMENT_ID" ] || [ -z "$DEPLOYMENT_HOST" ]; then
echo "Vercel response did not include a deployment ID and URL." >&2
exit 1
fi

{
echo "deployment_id=$DEPLOYMENT_ID"
echo "deployment_url=https://$DEPLOYMENT_HOST"
} >> "$GITHUB_OUTPUT"

{
echo "## University Web redeploy"
echo "- Reason: $REDEPLOY_REASON"
echo "- Source branch: $VERCEL_RELEASE_BRANCH"
echo "- Source commit: $RELEASE_SHA"
echo "- Deployment: https://$DEPLOYMENT_HOST"
} >> "$GITHUB_STEP_SUMMARY"

- name: Wait for deployment
env:
DEPLOYMENT_ID: ${{ steps.deploy.outputs.deployment_id }}
run: |
set -euo pipefail

for attempt in $(seq 1 90); do
RESPONSE=$(curl --fail-with-body --silent --show-error \
--header "Authorization: Bearer $VERCEL_TOKEN" \
"https://api.vercel.com/v13/deployments/$DEPLOYMENT_ID?teamId=$VERCEL_ORG_ID")
STATE=$(jq -r '.readyState // "UNKNOWN"' <<< "$RESPONSE")

echo "Deployment state: $STATE"

case "$STATE" in
READY)
echo "- Result: READY" >> "$GITHUB_STEP_SUMMARY"
exit 0
;;
ERROR|CANCELED)
echo "- Result: $STATE" >> "$GITHUB_STEP_SUMMARY"
exit 1
;;
esac

sleep 10
done

echo "Vercel deployment did not finish within 15 minutes." >&2
exit 1
17 changes: 17 additions & 0 deletions docs/university-multizone-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ production university web project์˜ `NEXT_PUBLIC_WEB_URL`์€ ์‹ค์ œ ์‚ฌ์šฉ์ž
NEXT_PUBLIC_WEB_URL=https://www.solid-connection.com
```

## SSG ๋ฐ์ดํ„ฐ ์žฌ๋ฐฐํฌ

๋Œ€ํ•™ API ๋ฐ์ดํ„ฐ๋งŒ ๋ณ€๊ฒฝ๋œ ๊ฒฝ์šฐ์—๋Š” Git ๋ณ€๊ฒฝ์ด ์—†์–ด๋„ `Redeploy University Web` workflow๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. ์ด workflow๋Š” `release-university`์˜ ํ˜„์žฌ ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•ด university web production์„ ์ƒˆ๋กœ ๋นŒ๋“œํ•œ๋‹ค. ๋™์ผํ•œ ์ปค๋ฐ‹์˜ ๊ธฐ์กด ๋ฐฐํฌ๋ฅผ ์žฌ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ ๋นŒ๋“œ ์‹œ์ ์˜ ์ตœ์‹  API ๋ฐ์ดํ„ฐ๊ฐ€ SSG ํŽ˜์ด์ง€์— ๋ฐ˜์˜๋œ๋‹ค.

GitHub Actions ํ™”๋ฉด์—์„œ ์ˆ˜๋™์œผ๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. API ๋ฐ์ดํ„ฐ ๊ฐฑ์‹  ์ž‘์—…์—์„œ ์ž๋™ ํ˜ธ์ถœํ•˜๋ ค๋ฉด repository dispatch event type์„ `university-data-updated`๋กœ ์ „์†กํ•œ๋‹ค. ์„ ํƒ์ ์œผ๋กœ `client_payload.reason`์— ๊ฐฑ์‹  ์ด์œ ๋ฅผ ๋„ฃ์„ ์ˆ˜ ์žˆ๋‹ค.

```json
{
"event_type": "university-data-updated",
"client_payload": {
"reason": "๋Œ€ํ•™ API ์ดˆ๊ธฐ ๋ฐ์ดํ„ฐ ์ž…๋ ฅ ์™„๋ฃŒ"
}
}
```

workflow๋Š” ์ €์žฅ์†Œ์˜ `VERCEL_TOKEN`๊ณผ `VERCEL_ORG_ID` secret์„ ์‚ฌ์šฉํ•œ๋‹ค. ๋Œ€์ƒ ํ”„๋กœ์ ํŠธ๋Š” `solid-connect-university-web`์œผ๋กœ ๊ณ ์ •ํ•˜๋ฉฐ ๋‹ค๋ฅธ web๊ณผ admin ํ”„๋กœ์ ํŠธ๋Š” ์žฌ๋ฐฐํฌํ•˜์ง€ ์•Š๋Š”๋‹ค.

## Local Development

ํ„ฐ๋ฏธ๋„ ๋‘ ๊ฐœ์—์„œ ์‹คํ–‰ํ•œ๋‹ค.
Expand Down
Loading