-
-
Notifications
You must be signed in to change notification settings - Fork 21
Updated client config controller to reference updated script name #1330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -103,7 +103,7 @@ jobs: | |||||||||||||||||
| - name: Destroy Tests databases | ||||||||||||||||||
| if: ${{ steps.check-labels.outputs.is_ephemeral_staging == 'true' }} | ||||||||||||||||||
| env: | ||||||||||||||||||
| GCP_PROJECT: ghost-activitypub | ||||||||||||||||||
| GCP_PROJECT: ghost-activitypub-stg | ||||||||||||||||||
| run: | | ||||||||||||||||||
| TEST_DATABASES=$(gcloud sql databases list --instance=stg-netherlands-activitypub --filter="name~pr_${{ github.event.pull_request.number }}_test*" --format="value(name)" --project ${GCP_PROJECT}) | ||||||||||||||||||
| for TEST_DATABASE in ${TEST_DATABASES}; do | ||||||||||||||||||
|
|
@@ -114,28 +114,28 @@ jobs: | |||||||||||||||||
| if: ${{ steps.check-labels.outputs.is_ephemeral_staging == 'true' }} | ||||||||||||||||||
| env: | ||||||||||||||||||
| LABELS: ${{ toJson(github.event.pull_request.labels) }} | ||||||||||||||||||
| GCP_PROJECT: ghost-activitypub | ||||||||||||||||||
| GCP_PROJECT: ghost-activitypub-stg | ||||||||||||||||||
| run: | | ||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||
| # Get current config | ||||||||||||||||||
| gcloud compute url-maps export stg-activitypub --global --project ${GCP_PROJECT} > config.yml | ||||||||||||||||||
| # Delete unnecessary fields | ||||||||||||||||||
| yq -i 'del(.fingerprint)' config.yml | ||||||||||||||||||
| yq -i 'del(.creationTimestamp)' config.yml | ||||||||||||||||||
| export DEFAULT_SERVICE="https://www.googleapis.com/compute/v1/projects/ghost-activitypub/global/backendServices/stg-netherlands-activitypub-api" | ||||||||||||||||||
| export PR_SERVICE="https://www.googleapis.com/compute/v1/projects/ghost-activitypub/global/backendServices/stg-pr-${{ github.event.pull_request.number }}-api" | ||||||||||||||||||
| export DEFAULT_SERVICE="https://www.googleapis.com/compute/v1/projects/${GCP_PROJECT}/global/backendServices/stg-netherlands-activitypub-api" | ||||||||||||||||||
| export PR_SERVICE="https://www.googleapis.com/compute/v1/projects/${GCP_PROJECT}/global/backendServices/stg-pr-${{ github.event.pull_request.number }}-api" | ||||||||||||||||||
| # Add host rules and path matchers if they don't exist | ||||||||||||||||||
| yq -i '.hostRules = (.hostRules // [{"hosts": ["activitypub.ghostinfra.net"], "pathMatcher": "all-paths"}])' config.yml | ||||||||||||||||||
| yq -i '.pathMatchers = (.pathMatchers // [{"name": "all-paths", "defaultService": "'"$DEFAULT_SERVICE"'", "routeRules": []}])' config.yml | ||||||||||||||||||
| # Remove existing route rules for the PR service | ||||||||||||||||||
| yq -i '.pathMatchers[] |= (.routeRules |= map(select((.routeAction.weightedBackendServices // []) | length == 0 or .routeAction.weightedBackendServices[0].backendService != env(PR_SERVICE))))' config.yml | ||||||||||||||||||
| # Add new route rules for the PR service | ||||||||||||||||||
| export MAX_PRIORITY=$(yq '[.pathMatchers[] | select(.name == "all-paths") | .routeRules[]?.priority] | max // 0' config.yml) | ||||||||||||||||||
| export NEXT_PRIORITY=$((MAX_PRIORITY + 1)) | ||||||||||||||||||
| export MIN_PRIORITY=$(yq '[.pathMatchers[] | select(.name == "all-paths") | .routeRules[]?.priority] | min // 0' config.yml) | ||||||||||||||||||
| export NEXT_PRIORITY=$((MIN_PRIORITY - 1)) | ||||||||||||||||||
|
Comment on lines
+133
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against negative route priorities
- export MIN_PRIORITY=$(yq '[.pathMatchers[] | select(.name == "all-paths") | .routeRules[]?.priority] | min // 0' config.yml)
- export NEXT_PRIORITY=$((MIN_PRIORITY - 1))
+ export MIN_PRIORITY=$(yq '[.pathMatchers[] | select(.name == "all-paths") | .routeRules[]?.priority] | min // 1' config.yml)
+ if [ "$MIN_PRIORITY" -le 0 ]; then
+ export NEXT_PRIORITY=0
+ else
+ export NEXT_PRIORITY=$((MIN_PRIORITY - 1))
+ fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| LABELS_JSON=$(echo "$LABELS" | jq -c '[.[] | select(.name | test("\\.ghost\\.is$")) | .name]') | ||||||||||||||||||
| for LABEL in $(echo "$LABELS_JSON" | jq -r '.[]'); do | ||||||||||||||||||
| echo "Adding route for label: $LABEL" | ||||||||||||||||||
| yq -i '.pathMatchers[0].routeRules += [{"priority": '$NEXT_PRIORITY', "matchRules": [{"prefixMatch": "/", "headerMatches": [{ "headerName": "X-Forwarded-Host", "exactMatch": "'$LABEL'" }]}], "routeAction": {"weightedBackendServices": [ { "backendService": "'$PR_SERVICE'", "weight": 100 } ] }, "headerAction": { "requestHeadersToAdd": [ { "headerName": "X-ActivityPub-PR", "headerValue": "${{ github.event.pull_request.number }}" }, { "headerName": "X-ActivityPub-Commit", "headerValue": "${{ github.event.pull_request.head.sha }}" } ] } }]' config.yml | ||||||||||||||||||
| yq -i '.pathMatchers[0].routeRules = [{"priority": '${NEXT_PRIORITY}', "matchRules": [{"prefixMatch": "/", "headerMatches": [{"headerName": "X-Forwarded-Host", "exactMatch": "'"${LABEL}"'"}]}], "routeAction": {"weightedBackendServices": [{"backendService": "'"${PR_SERVICE}"'", "weight": 100}]}, "headerAction": {"requestHeadersToAdd": [{"headerName": "X-ActivityPub-PR", "headerValue": "${{ github.event.pull_request.number }}"}, {"headerName": "X-ActivityPub-Commit", "headerValue": "${{ github.event.pull_request.head.sha }}"}]}}] + .pathMatchers[0].routeRules' config.yml | ||||||||||||||||||
| export NEXT_PRIORITY=$((NEXT_PRIORITY + 1)) | ||||||||||||||||||
| done | ||||||||||||||||||
| echo "Updating url map with:" | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.