CivicNav - Azure AI Engineering Lab #1
This file contains hidden or 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
| # GitHub Actions workflow for CivicNav deployment | |
| # Triggered on push to main branch | |
| name: Deploy CivicNav to Azure | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '**.md' | |
| - '.github/copilot-instructions.md' | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| env: | |
| AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} | |
| AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} | |
| AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
| AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }} | |
| AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r requirements-dev.txt | |
| - name: Run tests | |
| run: | | |
| pytest tests/ -v --tb=short | |
| - name: Install Azure Developer CLI | |
| uses: Azure/[email protected] | |
| - name: Log in to Azure (Federated Credentials) | |
| run: | | |
| azd auth login ` | |
| --client-id "${{ env.AZURE_CLIENT_ID }}" ` | |
| --federated-credential-provider "github" ` | |
| --tenant-id "${{ env.AZURE_TENANT_ID }}" | |
| shell: pwsh | |
| - name: Provision and Deploy | |
| run: azd up --no-prompt | |
| env: | |
| AZURE_ENV_NAME: ${{ env.AZURE_ENV_NAME }} | |
| AZURE_LOCATION: ${{ env.AZURE_LOCATION }} | |
| AZURE_SUBSCRIPTION_ID: ${{ env.AZURE_SUBSCRIPTION_ID }} | |
| - name: Output deployment URL | |
| run: | | |
| echo "Deployment complete!" | |
| azd show --output json | jq -r '.services.api.endpoints[0]' |