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: 4 additions & 18 deletions .github/workflows/vm-start.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
name: Start environment

# Brings the Azure VM online for a demo. Creates a public IP, attaches it,
# starts the VM (containers auto-restart via `restart: unless-stopped`), and
# arms an auto-shutdown timer so the VM deallocates itself after `minutes`.
# starts the VM (containers auto-restart via `restart: unless-stopped`).
# The public URL is printed in the run summary.

on:
workflow_dispatch:
inputs:
minutes:
description: "Minutes to keep the VM running before it auto-shuts-down (e.g. 5, 60, 120)"
required: true
default: "120"

permissions:
id-token: write
Expand All @@ -29,25 +23,20 @@ jobs:
start:
runs-on: ubuntu-latest
steps:
- name: Get OIDC token & compute shutdown time
- name: Get OIDC token
id: prep
env:
MINUTES: ${{ github.event.inputs.minutes }}
run: |
TOKEN=$(curl -sS \
-H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" \
| jq -r '.value')
echo "::add-mask::$TOKEN"
echo "token=$TOKEN" >> "$GITHUB_OUTPUT"
echo "shutdown=$(date -u -d "+${MINUTES} minutes" +%H%M)" >> "$GITHUB_OUTPUT"

- name: Start the environment
uses: azure/cli@v2
env:
FED_TOKEN: ${{ steps.prep.outputs.token }}
SHUTDOWN: ${{ steps.prep.outputs.shutdown }}
MINUTES: ${{ github.event.inputs.minutes }}
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
Expand All @@ -67,17 +56,14 @@ jobs:
--resource-group "$RESOURCE_GROUP" --nic-name "$NIC_NAME" \
--name "$IP_CONFIG" --public-ip-address "$PIP_NAME" --only-show-errors
az vm start --resource-group "$RESOURCE_GROUP" --name "$VM_NAME"
az vm auto-shutdown \
--resource-group "$RESOURCE_GROUP" --name "$VM_NAME" --time "$SHUTDOWN"
IP=$(az network public-ip show \
--resource-group "$RESOURCE_GROUP" --name "$PIP_NAME" \
--query ipAddress -o tsv)
echo "Environment URL: http://$IP (auto-shutdown ${SHUTDOWN} UTC, in ${MINUTES} min)"
echo "Environment URL: http://$IP"
{
echo "### 🚀 Environment starting"
echo ""
echo "**URL:** http://$IP (allow ~1–2 min for containers to come up)"
echo ""
echo "Auto-shutdown armed for **${SHUTDOWN} UTC** (in ${MINUTES} min)."
echo "Run **Stop environment** to end early and release the IP."
echo "⚠️ Run **Stop environment** when you're done to stop billing."
} >> "$GITHUB_STEP_SUMMARY"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Rancher deployment (Kubernetes): https://devsecops.stud.k8s.aet.cit.tum.de

Azure deployment (Docker Compose): Unfortunately, all of us almost ran out of credits on Azure. Therefore, we can only serve it on-demand: [Run the `vm-start` workflow](https://github.com/AET-DevOps26/team-devsecops/actions/workflows/vm-start.yml) to activate an Azure instance for 2 hours (IP address will be printed in the logs).
Azure deployment (Docker Compose): Unfortunately, all of us almost ran out of credits on Azure. Therefore, we can only serve it on-demand: [Run the `vm-start` workflow](https://github.com/AET-DevOps26/team-devsecops/actions/workflows/vm-start.yml) to activate an Azure instance, and [run `vm-stop`](https://github.com/AET-DevOps26/team-devsecops/actions/workflows/vm-stop.yml).

Coverage reports: https://aet-devops26.github.io/team-devsecops/

Expand Down
Loading