Skip to content

Commit d87535b

Browse files
authored
Merge pull request #1 from code-workbench/km/initial_build
Building out demo
2 parents 57137fa + dbfcc3d commit d87535b

22 files changed

+2631
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Deploy Docker App to Azure Government Dev Environment
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
env:
11+
TF_VERSION: '1.5.0'
12+
13+
jobs:
14+
deploy-to-dev:
15+
name: 'Deploy to Dev Environment'
16+
runs-on: ubuntu-latest
17+
environment: dev
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
working-directory: .
23+
24+
steps:
25+
# Checkout the repository to the GitHub Actions runner
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
# Install the latest version of Terraform CLI
30+
- name: Setup Terraform
31+
uses: hashicorp/setup-terraform@v3
32+
with:
33+
terraform_version: ${{ env.TF_VERSION }}
34+
terraform_wrapper: false
35+
36+
# Configure Azure CLI for Azure Government
37+
- name: Configure Azure CLI for Azure Government
38+
run: |
39+
az cloud set --name AzureUSGovernment
40+
az cloud show --query name
41+
42+
# Login to Azure Government using the credentials
43+
- name: Azure Government Login
44+
uses: azure/login@v1
45+
with:
46+
creds: ${{ secrets.AZURE_CREDENTIALS }}
47+
environment: 'AzureUSGovernment'
48+
49+
# Extract credentials for Terraform environment variables
50+
- name: Set Terraform Environment Variables
51+
run: |
52+
echo "ARM_CLIENT_ID=$(echo '${{ secrets.AZURE_CREDENTIALS }}' | jq -r .clientId)" >> $GITHUB_ENV
53+
echo "ARM_CLIENT_SECRET=$(echo '${{ secrets.AZURE_CREDENTIALS }}' | jq -r .clientSecret)" >> $GITHUB_ENV
54+
echo "ARM_SUBSCRIPTION_ID=$(echo '${{ secrets.AZURE_CREDENTIALS }}' | jq -r .subscriptionId)" >> $GITHUB_ENV
55+
echo "ARM_TENANT_ID=$(echo '${{ secrets.AZURE_CREDENTIALS }}' | jq -r .tenantId)" >> $GITHUB_ENV
56+
echo "ARM_ENVIRONMENT=usgovernment" >> $GITHUB_ENV
57+
58+
# Make deploy script executable
59+
- name: Make deploy script executable
60+
run: chmod +x ./scripts/deploy-docker-app.sh
61+
62+
# Create terraform.tfvars for dev environment
63+
- name: Create terraform.tfvars for dev environment
64+
run: |
65+
cd infra
66+
cat > terraform.tfvars << EOF
67+
location = "${{ secrets.AZURE_LOCATION }}"
68+
environment = "dev"
69+
EOF
70+
71+
# Configure Terraform backend for remote state
72+
- name: Configure Terraform Backend
73+
run: |
74+
cd infra
75+
terraform init \
76+
-backend-config="resource_group_name=${{ secrets.TF_STATE_RESOURCE_GROUP }}" \
77+
-backend-config="storage_account_name=${{ secrets.TF_STATE_STORAGE_ACCOUNT }}" \
78+
-backend-config="container_name=${{ secrets.TF_STATE_CONTAINER_NAME }}" \
79+
-backend-config="key=dev/terraform.tfstate"
80+
81+
# Deploy infrastructure using the deploy script
82+
- name: Deploy Infrastructure to Dev
83+
run: ./scripts/deploy-docker-app.sh deploy dev
84+
85+
# Get Terraform outputs for subsequent steps
86+
- name: Get Terraform Outputs
87+
id: terraform-outputs
88+
run: |
89+
cd infra
90+
echo "container_registry_name=$(terraform output -raw container_registry_name)" >> $GITHUB_OUTPUT
91+
echo "app_service_name=$(terraform output -raw app_service_name)" >> $GITHUB_OUTPUT
92+
echo "resource_group_name=$(terraform output -raw resource_group_name)" >> $GITHUB_OUTPUT
93+
94+
# Build and push Docker image using the deploy script (only on main branch push)
95+
- name: Build and Push Docker Image to Dev
96+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
97+
run: ./scripts/deploy-docker-app.sh build-push ./app
98+
99+
# Restart App Service to pull the new image (only on main branch push)
100+
- name: Restart Dev App Service
101+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
102+
run: |
103+
az webapp restart --name ${{ steps.terraform-outputs.outputs.app_service_name }} --resource-group ${{ steps.terraform-outputs.outputs.resource_group_name }}
104+
105+
# Show deployment summary using the deploy script
106+
- name: Show Deployment Summary
107+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
108+
run: ./scripts/deploy-docker-app.sh outputs

.gitignore

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
crash.*.log
11+
12+
# Exclude all .tfvars files, which are likely to contain sensitive data
13+
*.tfvars
14+
*.tfvars.json
15+
# But keep example files
16+
!*.tfvars.example
17+
18+
# Ignore override files as they are usually used to override resources locally
19+
override.tf
20+
override.tf.json
21+
*_override.tf
22+
*_override.tf.json
23+
24+
# Include override files you do wish to add to version control using negated pattern
25+
# !example_override.tf
26+
27+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
28+
*tfplan*
29+
30+
# Ignore CLI configuration files
31+
.terraformrc
32+
terraform.rc
33+
34+
# Ignore Mac .DS_Store files
35+
.DS_Store
36+
37+
# Ignore Windows thumbs.db files
38+
Thumbs.db
39+
40+
# Ignore editor backup files
41+
*~
42+
*.swp
43+
*.swo
44+
*#
45+
.#*
46+
47+
# Ignore IDE files
48+
.idea/
49+
*.iml
50+
*.ipr
51+
*.iws
52+
53+
# Azure CLI
54+
.azure/
55+
56+
# Terraform provider cache
57+
# .terraform.lock.hcl
58+
.terraform.lock.hcl
59+
60+
# Environment variables
61+
.env
62+
.env.local
63+
.env.*.local
64+
65+
# IDE files
66+
.vscode/settings.json
67+
.idea/
68+
*.swp
69+
*.swo
70+
71+
# OS files
72+
.DS_Store
73+
Thumbs.db
74+
75+
# Logs
76+
*.log
77+
logs/
78+
79+
# Node.js (if using Node.js example)
80+
node_modules/
81+
npm-debug.log*
82+
yarn-debug.log*
83+
yarn-error.log*
84+
85+
# Docker
86+
.dockerignore
87+
88+
# Azure CLI
89+
.azure/
90+
91+
# Terraform plans
92+
*.tfplan
93+
94+
# Temporary files
95+
*.tmp
96+
*.bak
97+
*~

.vscode/extensions.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"recommendations": [
3+
"hashicorp.terraform",
4+
"ms-vscode.azure-account",
5+
"ms-azuretools.vscode-azureterraform",
6+
"ms-azuretools.vscode-azureresourcegroups",
7+
"ms-azuretools.vscode-azurestorage",
8+
"ms-vscode.vscode-json",
9+
"redhat.vscode-yaml",
10+
"ms-vscode.makefile-tools",
11+
"github.vscode-github-actions",
12+
"ms-vscode.powershell",
13+
"ms-azure-devops.azure-pipelines",
14+
"streetsidesoftware.code-spell-checker",
15+
"ms-vscode.vscode-typescript-next",
16+
"gruntfuggly.todo-tree",
17+
"oderwat.indent-rainbow",
18+
"christian-kohler.path-intellisense",
19+
"formulahendry.auto-rename-tag",
20+
"bradlc.vscode-tailwindcss"
21+
],
22+
"unwantedRecommendations": [
23+
"ms-vscode.vscode-typescript"
24+
]
25+
}

.vscode/keybindings.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[
2+
{
3+
"key": "ctrl+shift+t ctrl+shift+p",
4+
"command": "workbench.action.tasks.runTask",
5+
"args": "Terraform: Plan",
6+
"when": "editorTextFocus"
7+
},
8+
{
9+
"key": "ctrl+shift+t ctrl+shift+a",
10+
"command": "workbench.action.tasks.runTask",
11+
"args": "Terraform: Apply",
12+
"when": "editorTextFocus"
13+
},
14+
{
15+
"key": "ctrl+shift+t ctrl+shift+v",
16+
"command": "workbench.action.tasks.runTask",
17+
"args": "Terraform: Validate",
18+
"when": "editorTextFocus"
19+
},
20+
{
21+
"key": "ctrl+shift+t ctrl+shift+f",
22+
"command": "workbench.action.tasks.runTask",
23+
"args": "Terraform: Format",
24+
"when": "editorTextFocus"
25+
},
26+
{
27+
"key": "ctrl+shift+t ctrl+shift+i",
28+
"command": "workbench.action.tasks.runTask",
29+
"args": "Terraform: Initialize",
30+
"when": "editorTextFocus"
31+
},
32+
{
33+
"key": "ctrl+shift+t ctrl+shift+o",
34+
"command": "workbench.action.tasks.runTask",
35+
"args": "Terraform: Show Outputs",
36+
"when": "editorTextFocus"
37+
},
38+
{
39+
"key": "ctrl+shift+a ctrl+shift+g",
40+
"command": "workbench.action.tasks.runTask",
41+
"args": "Azure Gov: Check Configuration",
42+
"when": "editorTextFocus"
43+
},
44+
{
45+
"key": "ctrl+shift+a ctrl+shift+s",
46+
"command": "workbench.action.tasks.runTask",
47+
"args": "Azure Gov: Setup Government Cloud",
48+
"when": "editorTextFocus"
49+
},
50+
{
51+
"key": "ctrl+shift+a ctrl+shift+d",
52+
"command": "workbench.action.tasks.runTask",
53+
"args": "Azure Gov: Full Deployment",
54+
"when": "editorTextFocus"
55+
},
56+
{
57+
"key": "ctrl+shift+s ctrl+shift+c",
58+
"command": "workbench.action.tasks.runTask",
59+
"args": "Azure Gov: Security Check",
60+
"when": "editorTextFocus"
61+
},
62+
{
63+
"key": "ctrl+shift+d ctrl+shift+w",
64+
"command": "workbench.action.tasks.runTask",
65+
"args": "Deploy: Complete Workflow",
66+
"when": "editorTextFocus"
67+
},
68+
{
69+
"key": "ctrl+shift+h",
70+
"command": "workbench.action.tasks.runTask",
71+
"args": "Azure Gov: Help",
72+
"when": "editorTextFocus"
73+
}
74+
]

0 commit comments

Comments
 (0)