Skip to content

Commit e78d9a1

Browse files
committed
Initial commit with latest state
0 parents  commit e78d9a1

180 files changed

Lines changed: 29201 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
3+
"features": {
4+
"ghcr.io/devcontainers/features/github-cli:1": {},
5+
"ghcr.io/devcontainers/features/go:1": {
6+
"version": "1.24"
7+
},
8+
"ghcr.io/github/features/goproxy:1": {},
9+
"ghcr.io/github/features/go-linter:2": {},
10+
"ghcr.io/devcontainers/features/sshd:1": {
11+
"version": "latest"
12+
},
13+
"ghcr.io/devcontainers/features/node:1": {
14+
"nodeGypDependencies": true,
15+
"version": "lts",
16+
"nvmVersion": "latest"
17+
},
18+
"ghcr.io/devcontainers/features/hugo:1": {
19+
"extended": true,
20+
"version": "latest"
21+
}
22+
},
23+
"onCreateCommand": ".devcontainer/on-create-command.sh",
24+
"postCreateCommand": "./tools/setup",
25+
"containerEnv": {
26+
"GOPROXY": "https://goproxy.githubapp.com/mod,https://proxy.golang.org/,direct",
27+
"GOPRIVATE": "",
28+
"GONOPROXY": "",
29+
"GONOSUMDB": "github.com/github/*"
30+
},
31+
"customizations": {
32+
"vscode": {
33+
"extensions": [
34+
"golang.go",
35+
// Recommended for Hextra theme
36+
"mhutchie.git-graph",
37+
"esbenp.prettier-vscode",
38+
"tamasfe.even-better-toml",
39+
"budparr.language-hugo-vscode",
40+
41+
// Recommended extensions from https://gohugo.io/tools/editors/#visual-studio-code
42+
// Front Matter CMS: https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-front-matter
43+
"eliostruyf.vscode-front-matter",
44+
45+
// Hugo Helper: https://marketplace.visualstudio.com/items?itemName=rusnasonov.vscode-hugo
46+
"rusnasonov.vscode-hugo",
47+
48+
// Hugo Language and Syntax Support: https://marketplace.visualstudio.com/items?itemName=budparr.language-hugo-vscode
49+
"budparr.language-hugo-vscode",
50+
51+
// Hugo Themer: https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-hugo-themer
52+
"eliostruyf.vscode-hugo-themer",
53+
54+
// hugofy: https://marketplace.visualstudio.com/items?itemName=akmittal.hugofy
55+
"akmittal.hugofy",
56+
57+
// Hugo Shortcode Syntax Highlighting: https://marketplace.visualstudio.com/items?itemName=kaellarkin.hugo-shortcode-syntax
58+
"kaellarkin.hugo-shortcode-syntax"
59+
],
60+
"settings": {
61+
"go.lintFlags": [
62+
"--config=/workspaces/.golangci.toml",
63+
"--whole-files",
64+
"--new-from-rev=origin/main"
65+
]
66+
}
67+
},
68+
"codespaces": {
69+
"repositories": {
70+
"github/go-linter": {
71+
"permissions": {
72+
"contents": "read",
73+
"packages": "read"
74+
}
75+
},
76+
"github/features": {
77+
"permissions": {
78+
"contents": "read",
79+
"packages": "read"
80+
}
81+
},
82+
"github/*": {
83+
"permissions": {
84+
"contents": "read",
85+
"packages": "read"
86+
}
87+
}
88+
}
89+
}
90+
},
91+
"forwardPorts": [1313],
92+
"portsAttributes": {
93+
"8080": {
94+
"label": "dev-server"
95+
}
96+
}
97+
}

.devcontainer/on-create-command.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
set -e
3+
4+
5+
/usr/local/share/goproxy-init.sh
6+
/usr/local/share/go-linter-init.sh

.github/CODEOWNERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
# Default owners for all files in the repository
3+
* @github/github-well-architected-admins @github/cse-intelligence-engine-squad @bot-digital-customer-success @github/github-well-architected-maintainers
4+
5+
# Owners for .github and script directories
6+
# This includes CICD workflows, and other CSE-specific configurations
7+
/.github/ @github/github-well-architected-admins @github/cse-intelligence-engine-squad @bot-digital-customer-success

.github/dependabot.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
labels:
8+
- "CI/CD"
9+
- "dependabot"
10+
commit-message:
11+
prefix: ci
12+
groups:
13+
actions-deps:
14+
patterns:
15+
- "*"
16+
- package-ecosystem: "npm"
17+
directory: "/"
18+
schedule:
19+
interval: "weekly"
20+
groups:
21+
npm-deps:
22+
patterns:
23+
- "*"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fail-on-severity: moderate
2+
3+
comment-summary-in-pr: always
4+
5+
# allow-licenses:
6+
# - MIT
7+
8+
fail-on-scopes:
9+
- development
10+
- runtime
11+
- unknown

.github/linters/.markdownlint.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"default": true,
3+
"MD013": false,
4+
"MD033": false,
5+
"MD060": false
6+
}
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
name: Merge Contribution to Internal
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
checks: read
11+
actions: read
12+
13+
jobs:
14+
check-merge-state:
15+
if: github.event.review.state == 'approved'
16+
runs-on: ubuntu-latest
17+
env:
18+
PR_NUMBER: ${{ github.event.pull_request.number }}
19+
SOURCE_REPO: ${{ github.repository }}
20+
outputs:
21+
checks_passed: ${{ steps.verify_checks.outputs.checks_passed }}
22+
steps:
23+
- name: Wait for Status Checks and Verify
24+
id: verify_checks
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
MAX_ATTEMPTS=120 # 120 attempts * 30 seconds = 60 minutes max
29+
ATTEMPT=0
30+
31+
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
32+
echo "Checking status checks (attempt $((ATTEMPT + 1))/$MAX_ATTEMPTS)..."
33+
34+
# Get PR status checks
35+
STATUS_JSON=$(gh pr view $PR_NUMBER --json statusCheckRollup --repo $SOURCE_REPO)
36+
37+
# Filter for CheckRun entries only and not this current job
38+
CHECK_RUNS=$(echo "$STATUS_JSON" | jq '[.statusCheckRollup[] | select(.__typename == "CheckRun") | select(.name != "check-merge-state" and .name != "dispatch-to-internal")]')
39+
40+
# Check if all checks are completed
41+
INCOMPLETE_COUNT=$(echo "$CHECK_RUNS" | jq '[.[] | select(.status != "COMPLETED")] | length')
42+
43+
if [ "$INCOMPLETE_COUNT" -eq 0 ]; then
44+
echo "All checks are completed!"
45+
46+
# Check conclusions - must be SUCCESS, NEUTRAL, or SKIPPED
47+
FAILED_CHECKS=$(echo "$CHECK_RUNS" | jq '[.[] | select(.conclusion != "SUCCESS" and .conclusion != "NEUTRAL" and .conclusion != "SKIPPED")]')
48+
FAILED_COUNT=$(echo "$FAILED_CHECKS" | jq 'length')
49+
50+
if [ "$FAILED_COUNT" -eq 0 ]; then
51+
echo "All checks passed with acceptable conclusions!"
52+
echo "checks_passed=true" >> $GITHUB_OUTPUT
53+
break
54+
else
55+
echo "Some checks failed:"
56+
echo "$FAILED_CHECKS" | jq -r '.[] | " - \(.name): \(.conclusion)"'
57+
echo "checks_passed=false" >> $GITHUB_OUTPUT
58+
exit 1
59+
fi
60+
else
61+
echo "$INCOMPLETE_COUNT checks still running. Waiting 30 seconds..."
62+
ATTEMPT=$((ATTEMPT + 1))
63+
if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
64+
sleep 30
65+
fi
66+
fi
67+
done
68+
69+
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
70+
echo "Timed out waiting for checks to complete"
71+
echo "checks_passed=false" >> $GITHUB_OUTPUT
72+
exit 1
73+
fi
74+
75+
# OSS App
76+
- name: Generate GitHub App Token
77+
id: pr_app_token
78+
uses: actions/create-github-app-token@v2
79+
with:
80+
app-id: ${{ vars.WELLARCHITECTED_OSS_APP_ID }}
81+
private-key: ${{ secrets.WELLARCHITECTED_OSS_APP_PRIVATE_KEY }}
82+
owner: github
83+
repositories: |
84+
github-well-architected
85+
permission-pull-requests: write
86+
permission-contents: write
87+
88+
- name: Enable Auto-Merge
89+
if: steps.verify_checks.outputs.checks_passed == 'true'
90+
env:
91+
GH_TOKEN: ${{ steps.pr_app_token.outputs.token }}
92+
run: |
93+
echo "Enabling auto-merge for PR #$PR_NUMBER..."
94+
gh pr merge $PR_NUMBER --auto --squash --repo $SOURCE_REPO
95+
echo "Auto-merge enabled successfully!"
96+
97+
dispatch-to-internal:
98+
needs: check-merge-state
99+
if: needs.check-merge-state.outputs.checks_passed == 'true' && github.event.review.state == 'approved'
100+
runs-on: ubuntu-latest
101+
env:
102+
SOURCE_REPO: github/github-well-architected
103+
TARGET_REPO: github/github-well-architected-internal
104+
PR_HEAD_BRANCH: ${{ github.event.pull_request.head.ref }}
105+
PR_NUMBER: ${{ github.event.pull_request.number }}
106+
ENVIRONMENT: staging
107+
steps:
108+
# OSS App
109+
- name: Generate GitHub App Token
110+
id: dispatch_app_token
111+
uses: actions/create-github-app-token@v2
112+
with:
113+
app-id: ${{ vars.WELLARCHITECTED_OSS_APP_ID }}
114+
private-key: ${{ secrets.WELLARCHITECTED_OSS_APP_PRIVATE_KEY }}
115+
owner: github
116+
repositories: |
117+
github-well-architected
118+
github-well-architected-internal
119+
permission-deployments: write
120+
permission-contents: write
121+
122+
- name: Create deployment
123+
id: create_deployment
124+
env:
125+
GH_TOKEN: ${{ steps.dispatch_app_token.outputs.token }}
126+
run: |
127+
################################################################
128+
# Check for existing deployments
129+
# If found, delete the latest one to avoid outdated deployments
130+
131+
EXISTING_DEPLOYMENT_LATEST=$(gh api \
132+
-H "Accept: application/vnd.github+json" \
133+
-H "X-GitHub-Api-Version: 2022-11-28" \
134+
"/repos/$SOURCE_REPO/deployments?ref=$PR_HEAD_BRANCH&environment=$ENVIRONMENT" \
135+
--jq '[.[] | select(.task == "deploy")] | sort_by(.created_at) | reverse | .[0].id // empty')
136+
137+
if [ -n "$EXISTING_DEPLOYMENT_LATEST" ] && [ "$EXISTING_DEPLOYMENT_LATEST" != "null" ]; then
138+
echo "Found existing deployment with ID: $EXISTING_DEPLOYMENT_LATEST"
139+
echo "existing_deployment_id=$EXISTING_DEPLOYMENT_LATEST" >> $GITHUB_OUTPUT
140+
141+
# Delete existing deployment
142+
gh api \
143+
--method DELETE \
144+
-H "Accept: application/vnd.github+json" \
145+
-H "X-GitHub-Api-Version: 2022-11-28" \
146+
/repos/$SOURCE_REPO/deployments/$EXISTING_DEPLOYMENT_LATEST
147+
fi
148+
149+
################################################################
150+
# Create new deployment
151+
152+
DEPLOYMENT_RESPONSE=$(gh api \
153+
--method POST \
154+
-H "Accept: application/vnd.github+json" \
155+
-H "X-GitHub-Api-Version: 2022-11-28" \
156+
/repos/$SOURCE_REPO/deployments \
157+
--input - <<-EOF
158+
{
159+
"ref": "$PR_HEAD_BRANCH",
160+
"environment": "$ENVIRONMENT",
161+
"description": "Deploy requested from PR $PR_NUMBER (branch: $PR_HEAD_BRANCH)",
162+
"auto_merge": false,
163+
"required_contexts": []
164+
}
165+
EOF
166+
)
167+
DEPLOYMENT_ID=$(echo "$DEPLOYMENT_RESPONSE" | jq -r '.id')
168+
echo "deployment_id=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT
169+
echo "Created new deployment with ID: $DEPLOYMENT_ID"
170+
171+
- name: Update Deployment Status
172+
env:
173+
GH_TOKEN: ${{ steps.dispatch_app_token.outputs.token }}
174+
NEW_DEPLOYMENT_ID: ${{ steps.create_deployment.outputs.deployment_id }}
175+
EXISTING_DEPLOYMENT_LATEST: ${{ steps.create_deployment.outputs.existing_deployment_id }}
176+
run: |
177+
gh api \
178+
--method POST \
179+
-H "Accept: application/vnd.github+json" \
180+
-H "X-GitHub-Api-Version: 2022-11-28" \
181+
/repos/$SOURCE_REPO/deployments/$NEW_DEPLOYMENT_ID/statuses \
182+
-f "state=in_progress" \
183+
-f "description=Deployment dispatched to internal repository for processing."
184+
185+
- name: Repository Dispatch to Internal Repo
186+
env:
187+
GH_TOKEN: ${{ steps.dispatch_app_token.outputs.token }}
188+
run: |
189+
gh api \
190+
--method POST \
191+
-H "Accept: application/vnd.github+json" \
192+
-H "X-GitHub-Api-Version: 2022-11-28" \
193+
/repos/$TARGET_REPO/dispatches \
194+
-f 'event_type=opensource-sync-to-publish' \
195+
-f "client_payload[pr_url]=${{ github.event.pull_request.html_url }}" \
196+
-f "client_payload[pr_number]=$PR_NUMBER" \
197+
-f "client_payload[head_ref]=$PR_HEAD_BRANCH" \

0 commit comments

Comments
 (0)