Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
21226ee
Agents setup
dharakumarmsft Feb 21, 2025
f3834e2
Add workflow file for Agent Setup
dharakumarmsft Feb 21, 2025
7a2d800
Add workflow file for Agent Setup
dharakumarmsft Feb 21, 2025
9e822ee
Update workflow event
dharakumarmsft Feb 21, 2025
17c1a94
Update workflow event
dharakumarmsft Feb 21, 2025
6b6e2dd
Added readme
dharakumarmsft Feb 21, 2025
c436f17
Fix workflow
dharakumarmsft Feb 21, 2025
d674ece
Fix workflow
dharakumarmsft Feb 21, 2025
cac0f04
Remove linting and scan folder setup
dharakumarmsft Feb 21, 2025
601475c
scan folder setup
dharakumarmsft Feb 21, 2025
eb4e7b4
scan folder setup
dharakumarmsft Feb 21, 2025
d337a7e
Fix typo
dharakumarmsft Feb 21, 2025
45a0d6e
Fix for main.bicep and azuredeploy.json
dharakumarmsft Feb 21, 2025
438a064
Fix typo
dharakumarmsft Feb 21, 2025
bfeed4c
Fix typo
dharakumarmsft Feb 21, 2025
f6aa2a8
Fix typo
dharakumarmsft Feb 21, 2025
4a3d41a
Fix typo
dharakumarmsft Feb 21, 2025
4b60bbe
Fix typo
dharakumarmsft Feb 21, 2025
4263935
Fix indentation
dharakumarmsft Feb 21, 2025
e610713
Remove exernal approver
dharakumarmsft Feb 21, 2025
42d7d0a
Fix typo
dharakumarmsft Feb 21, 2025
315d6b5
Fix indentation
dharakumarmsft Feb 21, 2025
03260f2
Fix typo
dharakumarmsft Feb 21, 2025
7b03f23
Fix typo
dharakumarmsft Feb 22, 2025
c8c09a3
Fix scan
dharakumarmsft Feb 22, 2025
010c098
Build bicep git hooks
dharakumarmsft Feb 22, 2025
2bda4c8
Build bicep git hooks
dharakumarmsft Feb 22, 2025
fc8b0e8
Build bicep git hooks
dharakumarmsft Feb 22, 2025
740ca47
Build bicep git hooks
dharakumarmsft Feb 22, 2025
f592197
Build bicep git hooks
dharakumarmsft Feb 22, 2025
434b12e
Build bicep git hooks
dharakumarmsft Feb 22, 2025
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
99 changes: 99 additions & 0 deletions .github/scripts/build_bicep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash

echo "Running pre-commit hook for Bicep builds..."

# Ensure shell profile is sourced to load environment variables
source ~/.bashrc || source ~/.bash_profile || source ~/.zshrc

# Function to manually install Bicep if az bicep install fails
install_bicep_manually() {
echo "⚠️ Trying to manually install Bicep..."

# Create install directory
INSTALL_PATH="$RUNNER_TEMP/bicep"
BICEP_PATH="$INSTALL_PATH/bicep"
mkdir -p $INSTALL_PATH

# Fetch the latest Bicep CLI binary
OS=$(uname -s)
case "$OS" in
Linux)
echo "🔹 Detected Linux. Installing Bicep..."
curl -sLo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
;;
Darwin)
echo "🔹 Detected macOS. Installing Bicep..."
curl -sLo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-osx-x64
;;
CYGWIN*|MINGW*|MSYS*)
echo "🔹 Detected Windows. Installing Bicep..."
curl -sLo bicep.exe https://github.com/Azure/bicep/releases/latest/download/bicep-win-x64.exe
mv bicep.exe "$INSTALL_PATH/bicep.exe"
;;
*)
echo "❌ Unsupported OS: $OS"
exit 1
;;
esac

chmod +x ./bicep
sudo mv ./bicep $INSTALL_PATH
export PATH="$INSTALL_PATH:$PATH"

echo "✅ Using Bicep at $BICEP_PATH"
$BICEP_PATH --version
}

# Check if Bicep CLI is installed
if ! command -v bicep &> /dev/null; then
echo "⚠️ Bicep CLI is not installed. Trying to install via Azure CLI..."

# Attempt installation via Azure CLI
az bicep install || install_bicep_manually

# Refresh environment
export PATH="$HOME/.azure/bin:$PATH"
source ~/.bashrc || source ~/.bash_profile || source ~/.zshrc
fi

echo "✅ Bicep CLI is installed: $(which bicep)"

# Find modified main.bicep files in the Agents/setup/ folder
REPO_ROOT=$(git rev-parse --show-toplevel) # Get the repo root directory
MODIFIED_BICEP_FILES=$(git diff --cached --name-only | find "$REPO_ROOT/scenarios/Agents/setup/" -type f -name "main.bicep")

if [ -z "$MODIFIED_BICEP_FILES" ]; then
echo "No modified Bicep files detected. Skipping build."
exit 0
fi

echo "Found modified Bicep files:"
echo "$MODIFIED_BICEP_FILES"

EXIT_CODE=0

# Loop through each modified Bicep file and build it
for BICEP_FILE in $MODIFIED_BICEP_FILES; do
BICEP_DIR=$(dirname "$BICEP_FILE") # Get directory of main.bicep
JSON_FILE="$BICEP_DIR/azuredeploy.json" # Force output to azuredeploy.json
echo "Building: $BICEP_FILE -> $JSON_FILE"

# Run Bicep build
if ! bicep build "$BICEP_FILE" --outfile "$JSON_FILE" 2>&1 | tee /tmp/bicep_error.log; then
echo "❌ Failed to build $BICEP_FILE"
cat /tmp/bicep_error.log
EXIT_CODE=1
else
# Stage the built JSON file for commit
git add "$JSON_FILE"
fi
done

# Abort commit if any Bicep file failed to compile
if [ "$EXIT_CODE" -ne 0 ]; then
echo "Pre-commit hook failed. Fix Bicep errors before committing."
exit 1
fi

echo "Bicep files successfully built and staged!"
exit 0
6 changes: 5 additions & 1 deletion .github/workflows/run-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ on:
branches:
- main
paths:
- scenarios/**
- .infra/deployments/**/*.bicep
push:
branches:
- main
paths-ignore:
- scenarios/Agents/setup/**
jobs:
check-if-external:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ repos:
entry: python .github/scripts/detect_azure_secrets.py
language: python
types: [file]
- id: bicep-build
name: Build Bicep files before commit
description: "Automatically build Bicep files into azuredeploy.json before commit"
entry: .github/scripts/build_bicep.sh
language: system
require_serial: true
pass_filenames: false
types: [file]
1 change: 1 addition & 0 deletions scenarios/Agents/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

50 changes: 50 additions & 0 deletions scenarios/Agents/media/deploytoazure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions scenarios/Agents/media/visualizebutton.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading