stop-cluster #1122
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: stop-cluster | |
on: | |
workflow_dispatch: | |
schedule: | |
# - cron: '0 16 * * 1-5' #utc Summer time - Initial | |
# - cron: '0 18 * * 1-5' #utc Summer time - Runs second time if initial run did not succeed | |
- cron: '0 17 * * 1-5' #utc Winter time - Initial | |
- cron: '0 19 * * 1-5' #utc Winter time - Runs second time if initial run did not succeed | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
stop-dev-clusters: | |
runs-on: ubuntu-latest | |
environment: dev | |
env: | |
KV_GROUP: common-dev | |
ENVIROMENT: dev | |
steps: | |
- uses: actions/checkout@v4 #Clone Repo | |
- name: 'Az CLI login' | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ vars.AZURE_CLIENT_ID }} | |
tenant-id: ${{ vars.AZURE_TENANT_ID }} | |
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
- name: Get GitHub Public IP | |
id: github_public_ip | |
run: echo "ipv4=$(curl 'https://ifconfig.me/ip')" >> $GITHUB_OUTPUT | |
- name: Add GitHub IP to KeyVault | |
id: update_firewall | |
run: | | |
az keyvault network-rule add --name "radix-keyv-${{ env.ENVIROMENT}}" \ | |
--resource-group "${{ env.KV_GROUP}}" \ | |
--ip-address ${{ steps.github_public_ip.outputs.ipv4 }} >/dev/null | |
- name: Lets sleep for 30 seconds for FW rule to complete | |
run: sleep 30s | |
- name: Stop clusters | |
run: RADIX_ZONE_ENV=./scripts/radix-zone/radix_zone_dev.env TASK=stop .github/workflows/scripts/dailytasks.sh | |
- name: Revoke GitHub IP on KeyVault | |
if: ${{ steps.update_firewall.outcome == 'success' && !cancelled()}} # Always run this step even if previous step failed | |
run: | | |
az keyvault network-rule remove --name "radix-keyv-${{ env.ENVIROMENT}}" \ | |
--resource-group "${{ env.KV_GROUP}}" \ | |
--ip-address ${{ steps.github_public_ip.outputs.ipv4 }} >/dev/null | |