Skip to content
Merged
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
22 changes: 22 additions & 0 deletions .github/workflows/dev-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,25 @@ jobs:

echo "Deployment complete. Active: ${NEW_SLOT}(${NEW_PORT})"
'

- name: Update Prometheus scrape target (stage)
run: |
echo "${{ secrets.MONITORING_PRIVATE_KEY }}" > monitoring_key.pem
chmod 600 monitoring_key.pem

UPSTREAM_PORT=$(ssh -i deploy_key.pem -o StrictHostKeyChecking=no \
"${{ secrets.DEV_USERNAME }}@${{ secrets.DEV_HOST }}" \
"grep -oE 'server 127\.0\.0\.1:[0-9]+' /etc/nginx/conf.d/upstream.conf 2>/dev/null | grep -oE '[0-9]+$'")

if [ "$UPSTREAM_PORT" != "8080" ] && [ "$UPSTREAM_PORT" != "9080" ]; then
echo "Unexpected UPSTREAM_PORT: '${UPSTREAM_PORT}'" >&2
exit 1
fi

Comment thread
coderabbitai[bot] marked this conversation as resolved.
if [ "$UPSTREAM_PORT" = "8080" ]; then NEW_MGMT_PORT=8081; else NEW_MGMT_PORT=9081; fi

ssh -i monitoring_key.pem -o StrictHostKeyChecking=no \
"${{ secrets.MONITORING_USERNAME }}@${{ secrets.MONITORING_HOST }}" \
"echo '[{\"targets\":[\"${{ secrets.DEV_HOST }}:${NEW_MGMT_PORT}\"]}]' \
| tee ~/solid-connection-monitor/prometheus/targets/stage.json > /dev/null \
Comment thread
coderabbitai[bot] marked this conversation as resolved.
&& echo 'Prometheus target updated: ${{ secrets.DEV_HOST }}:${NEW_MGMT_PORT}'"
22 changes: 22 additions & 0 deletions .github/workflows/prod-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,25 @@ jobs:

echo "Deployment complete. Active: ${NEW_SLOT}(${NEW_PORT})"
'

- name: Update Prometheus scrape target (prod)
run: |
echo "${{ secrets.MONITORING_PRIVATE_KEY }}" > monitoring_key.pem
chmod 600 monitoring_key.pem

UPSTREAM_PORT=$(ssh -i deploy_key.pem -o StrictHostKeyChecking=no \
"${{ secrets.USERNAME }}@${{ secrets.HOST }}" \
"grep -oE 'server 127\.0\.0\.1:[0-9]+' /etc/nginx/conf.d/upstream.conf 2>/dev/null | grep -oE '[0-9]+$'")

if [ "$UPSTREAM_PORT" != "8080" ] && [ "$UPSTREAM_PORT" != "9080" ]; then
echo "Unexpected UPSTREAM_PORT: '${UPSTREAM_PORT}'" >&2
exit 1
fi

if [ "$UPSTREAM_PORT" = "8080" ]; then NEW_MGMT_PORT=8081; else NEW_MGMT_PORT=9081; fi

ssh -i monitoring_key.pem -o StrictHostKeyChecking=no \
"${{ secrets.MONITORING_USERNAME }}@${{ secrets.MONITORING_HOST }}" \
"echo '[{\"targets\":[\"${{ secrets.HOST }}:${NEW_MGMT_PORT}\"]}]' \
| tee ~/solid-connection-monitor/prometheus/targets/prod.json > /dev/null \
&& echo 'Prometheus target updated: ${{ secrets.HOST }}:${NEW_MGMT_PORT}'"
Loading