|
3 | 3 | # OPTIONAL: BoJ Server Build Trigger |
4 | 4 | # This workflow notifies a BoJ Server instance when code is pushed. |
5 | 5 | # It is a no-op if BOJ_SERVER_URL is not set or the server is unreachable. |
6 | | -# To enable: set the BOJ_SERVER_URL repository secret (e.g., http://boj-server.local:7700) |
7 | | -# To disable: delete this file or leave the secret unset. |
8 | | -# |
| 6 | +# To enable: set BOJ_SERVER_URL as a repository secret or variable. |
| 7 | +# To disable: delete this file or leave BOJ_SERVER_URL unset. |
9 | 8 | name: BoJ Server Build Trigger |
| 9 | + |
10 | 10 | on: |
11 | 11 | push: |
12 | 12 | branches: [main, master] |
13 | 13 | workflow_dispatch: |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
14 | 18 | jobs: |
15 | 19 | trigger-boj: |
16 | 20 | runs-on: ubuntu-latest |
17 | 21 | if: ${{ vars.BOJ_SERVER_URL != '' || secrets.BOJ_SERVER_URL != '' }} |
18 | 22 | steps: |
19 | 23 | - name: Checkout |
20 | 24 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 25 | + |
21 | 26 | - name: Trigger BoJ Server (Casket/ssg-mcp) |
22 | 27 | env: |
23 | 28 | BOJ_URL: ${{ secrets.BOJ_SERVER_URL || vars.BOJ_SERVER_URL }} |
| 29 | + REPO_NAME: ${{ github.repository }} |
| 30 | + BRANCH_NAME: ${{ github.ref_name }} |
24 | 31 | run: | |
| 32 | + set -euo pipefail |
| 33 | +
|
25 | 34 | if [ -z "$BOJ_URL" ]; then |
26 | | - echo "BOJ_SERVER_URL not configured — skipping" |
| 35 | + echo "BOJ_SERVER_URL not configured - skipping" |
27 | 36 | exit 0 |
28 | 37 | fi |
| 38 | +
|
| 39 | + payload="$(jq -cn \ |
| 40 | + --arg repo "$REPO_NAME" \ |
| 41 | + --arg branch "$BRANCH_NAME" \ |
| 42 | + --arg engine "casket" \ |
| 43 | + '{repo:$repo, branch:$branch, engine:$engine}')" |
| 44 | +
|
29 | 45 | curl -sf -X POST "${BOJ_URL}/cartridges/ssg-mcp/invoke" \ |
30 | 46 | -H "Content-Type: application/json" \ |
31 | | - -d "{\"repo\": \"${{ github.repository }}\", \"branch\": \"${{ github.ref_name }}\", \"engine\": \"casket\"}" \ |
32 | | - || echo "BoJ server unreachable — skipping (non-fatal)" |
33 | | -permissions: |
34 | | - contents: read |
| 47 | + --data "$payload" \ |
| 48 | + || echo "BoJ server unreachable - skipping (non-fatal)" |
0 commit comments