Skip to content

Commit 843303a

Browse files
authored
Fix the baseof layout and update the project template (#3)
Signed-off-by: Artem Kladov <artem.kladov@flant.com>
1 parent f522e6d commit 843303a

File tree

14 files changed

+877
-7
lines changed

14 files changed

+877
-7
lines changed

layouts/baseof.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{- with .Site.Params.productCode }}
1212
{{- $partialPath = printf "header-%s.html" . }}
1313
{{- end }}
14-
{{- printf "<!-- #include virtual=\"/includes/%s\" -->" $partialPath | safeHTML }}
14+
{{- printf "<!--#include virtual=\"/includes/%s\" -->" $partialPath | safeHTML }}
1515

1616
<div class="container">
1717

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.github/ @z9r5
2+
.helm/ @z9r5
3+
.werf/ @z9r5
4+
config/ @z9r5
5+
go.* @z9r5
6+
werf.* @z9r5
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
name: Build Hugo Site
12+
concurrency:
13+
group: build-${{ github.event.pull_request.head.ref || github.ref_name }}
14+
cancel-in-progress: true
15+
container:
16+
image: hugomods/hugo:debian-ci-0.150.1
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
fetch-depth: 0
23+
24+
- name: Mark repository as safe
25+
run: git config --global --add safe.directory '${{ github.workspace }}'
26+
27+
- name: Build Hugo site
28+
run: hugo --minify --enableGitInfo=false
29+
30+
- name: Extract app name
31+
id: app_name
32+
shell: bash
33+
run: |
34+
REPO_NAME="${{ github.repository }}"
35+
REPO_NAME="${REPO_NAME#*/}"
36+
echo "Repository name: $REPO_NAME"
37+
if [[ "$REPO_NAME" =~ ^website- ]]; then
38+
APP_NAME="${REPO_NAME#website-}"
39+
else
40+
APP_NAME="$REPO_NAME"
41+
fi
42+
echo "app_name=$APP_NAME" >> $GITHUB_OUTPUT
43+
echo "App name: $APP_NAME"
44+
45+
- name: Rewrite URLs to remove /products/<APP>/ prefix
46+
run: |
47+
APP_NAME="${{ steps.app_name.outputs.app_name }}"
48+
find ./public/en ./public/ru -type f -name "*.html" -exec sed -i "s|/products/${APP_NAME}/|/|g" {} +
49+
50+
- name: Upload site artifacts
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: built-site
54+
path: public/
55+
retention-days: 1
56+
57+
check-links:
58+
runs-on: ubuntu-latest
59+
name: Check Links
60+
needs: build
61+
steps:
62+
- name: Download site artifacts
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: built-site
66+
path: .
67+
68+
- name: Install htmltest
69+
run: |
70+
curl https://htmltest.wjdp.uk | bash
71+
72+
- name: Create htmltest config
73+
run: |
74+
cat > .htmltest.yml << EOF
75+
IgnoreURLs:
76+
- "example.com"
77+
- "localhost"
78+
- "^/assets/"
79+
- "^/assets/js/"
80+
- "^/images/.+$"
81+
- "^/css/.+$"
82+
- "^/js/.+$"
83+
CheckMeta: false
84+
CheckLinks: false
85+
CheckMailto: false
86+
CheckTel: false
87+
CheckFavicon: false
88+
IgnoreInternalEmptyHash: true
89+
IgnoreCanonicalBrokenLinks: true
90+
EOF
91+
92+
- name: Check links (English)
93+
id: check_links_english
94+
continue-on-error: true
95+
run: bin/htmltest -c .htmltest.yml ./en
96+
97+
- name: Check links (Russian)
98+
id: check_links_russian
99+
continue-on-error: true
100+
run: bin/htmltest -c .htmltest.yml ./ru
101+
102+
- name: Fail job if any link check failed
103+
if: always()
104+
run: |
105+
if [ "${{ steps.check_links_english.outcome }}" == "failure" ] || [ "${{ steps.check_links_russian.outcome }}" == "failure" ]; then
106+
echo "One or more link checks failed"
107+
exit 1
108+
fi
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# WF for deploying to test/stage envs on PR label 'deploy/test' or 'deploy/stage'
2+
3+
name: Deploy on label
4+
5+
on:
6+
pull_request_target:
7+
types:
8+
- labeled
9+
10+
# Cancel in-progress jobs for the same tag/branch.
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.label.name }}-deploy
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
id-token: write
18+
issues: write
19+
pull-requests: write
20+
21+
jobs:
22+
deploy:
23+
runs-on: ubuntu-latest
24+
if: ${{ github.event.label.name == 'deploy/test' || github.event.label.name == 'deploy/stage' }}
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
ref: ${{ github.event.pull_request.head.sha }}
30+
submodules: recursive
31+
fetch-depth: 0
32+
33+
- name: Extract environment
34+
id: env
35+
run: |
36+
LABEL="${{ github.event.label.name }}"
37+
ENV="${LABEL#deploy/}"
38+
echo "env=$ENV" >> $GITHUB_OUTPUT
39+
40+
- name: Create deployment comment
41+
id: comment
42+
uses: actions/github-script@v7
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
script: |
46+
const env = '${{ steps.env.outputs.env }}';
47+
const comment = await github.rest.issues.createComment({
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
issue_number: context.payload.pull_request.number,
51+
body: `## 🚀 Deployment Started\n\n**Environment:** \`${env}\`\n\n_This comment will be updated with deployment status._`
52+
});
53+
core.setOutput('comment_id', comment.data.id);
54+
console.log(`Created comment: ${comment.data.id}`);
55+
56+
- name: Validate that Environment variable set
57+
run: |
58+
if [ -z "${{ steps.env.outputs.env }}" ]; then
59+
echo "::error::Can't determine environment name."
60+
exit 1
61+
fi
62+
echo "Environment: ${{ steps.env.outputs.env }}"
63+
64+
- name: Import secrets
65+
id: secrets
66+
uses: hashicorp/vault-action@v2
67+
with:
68+
url: https://seguro.flant.com
69+
path: github
70+
role: deckhouse-web-products
71+
method: jwt
72+
jwtGithubAudience: github-access-aud
73+
secrets: |
74+
projects/data/6db2f1ee-9b6f-4f4f-8381-2fb43060478a/github/registry_host DECKHOUSE_DEV_REGISTRY_HOST | DECKHOUSE_DEV_REGISTRY_HOST ;
75+
projects/data/6db2f1ee-9b6f-4f4f-8381-2fb43060478a/github/registry_host DECKHOUSE_REGISTRY_READ_HOST | DECKHOUSE_REGISTRY_READ_HOST ;
76+
projects/data/6db2f1ee-9b6f-4f4f-8381-2fb43060478a/github/registry_read_token login | DECKHOUSE_REGISTRY_READ_USER ;
77+
projects/data/6db2f1ee-9b6f-4f4f-8381-2fb43060478a/github/registry_read_token password | DECKHOUSE_REGISTRY_READ_PASSWORD ;
78+
projects/data/6db2f1ee-9b6f-4f4f-8381-2fb43060478a/github/documentation_deploy_secret KUBECONFIG_BASE64_DEV | KUBECONFIG_BASE64_DEV ;
79+
projects/data/101ceaca-97cd-462f-aed5-070d9b9de175/dev-registry/writetoken login | DECKHOUSE_DEV_REGISTRY_USER ;
80+
projects/data/101ceaca-97cd-462f-aed5-070d9b9de175/dev-registry/writetoken password | DECKHOUSE_DEV_REGISTRY_PASSWORD ;
81+
82+
- name: Check dev registry credentials
83+
id: check_dev_registry
84+
env:
85+
HOST: ${{steps.secrets.outputs.DECKHOUSE_DEV_REGISTRY_HOST}}
86+
run: |
87+
if [[ -n $HOST ]]; then
88+
echo "has_credentials=true" >> $GITHUB_OUTPUT
89+
echo "web_registry_path=${{steps.secrets.outputs.DECKHOUSE_DEV_REGISTRY_HOST }}/deckhouse/site" >> $GITHUB_OUTPUT
90+
fi
91+
92+
- name: Login to dev registry
93+
uses: docker/login-action@v3
94+
if: ${{ steps.check_dev_registry.outputs.has_credentials == 'true' }}
95+
with:
96+
registry: ${{ steps.secrets.outputs.DECKHOUSE_DEV_REGISTRY_HOST }}
97+
username: ${{ steps.secrets.outputs.DECKHOUSE_DEV_REGISTRY_USER }}
98+
password: ${{ steps.secrets.outputs.DECKHOUSE_DEV_REGISTRY_PASSWORD }}
99+
logout: false
100+
101+
- name: Check readonly registry credentials
102+
id: check_readonly_registry
103+
env:
104+
HOST: ${{ steps.secrets.outputs.DECKHOUSE_REGISTRY_READ_HOST }}
105+
run: |
106+
if [[ -n $HOST ]]; then
107+
echo "has_credentials=true" >> $GITHUB_OUTPUT
108+
echo "web_registry_path=${{ steps.secrets.outputs.DECKHOUSE_REGISTRY_READ_HOST }}/deckhouse/site" >> $GITHUB_OUTPUT
109+
fi
110+
111+
- name: Login to readonly registry
112+
uses: docker/login-action@v3
113+
if: ${{ steps.check_readonly_registry.outputs.has_credentials == 'true' }}
114+
with:
115+
registry: ${{ steps.secrets.outputs.DECKHOUSE_REGISTRY_READ_HOST }}
116+
username: ${{ steps.secrets.outputs.DECKHOUSE_REGISTRY_READ_USER }}
117+
password: ${{ steps.secrets.outputs.DECKHOUSE_REGISTRY_READ_PASSWORD }}
118+
logout: false
119+
120+
- name: Install werf
121+
uses: werf/actions/install@v2
122+
123+
- name: Deploy to ${{ steps.env.outputs.env }}
124+
id: deploy
125+
env:
126+
WERF_REPO: ${{ steps.check_dev_registry.outputs.web_registry_path }}
127+
WERF_ENV: ${{ steps.env.outputs.env }}
128+
WERF_KUBE_CONFIG_BASE64: ${{ steps.secrets.outputs.KUBECONFIG_BASE64_DEV }}
129+
WERF_SET_URL: "global.url=deckhouse.${{ steps.env.outputs.env }}.flant.com"
130+
WERF_SET_URL_RU: "global.url_ru=deckhouse.ru.${{ steps.env.outputs.env }}.flant.com"
131+
132+
run: |
133+
werf converge
134+
135+
- name: Update comment - deployment succeeded
136+
if: success()
137+
uses: actions/github-script@v7
138+
with:
139+
github-token: ${{ secrets.GITHUB_TOKEN }}
140+
script: |
141+
const env = '${{ steps.env.outputs.env }}';
142+
const commentId = ${{ steps.comment.outputs.comment_id }};
143+
const repoName = context.repo.repo;
144+
const appName = repoName.startsWith('website-') ? repoName.replace(/^website-/, '') : repoName;
145+
const urlEn = `https://deckhouse.${env}.flant.com/products/${appName}/documentation/`;
146+
const urlRu = `https://deckhouse.ru.${env}.flant.com/products/${appName}/documentation/`;
147+
148+
await github.rest.issues.updateComment({
149+
owner: context.repo.owner,
150+
repo: context.repo.repo,
151+
comment_id: commentId,
152+
body: `## ✅ Deployment Succeeded\n\n**Environment:** \`${env}\`\n\n**Access URLs:**\n\n- 🇬🇧 [English](${urlEn})\n- 🇷🇺 [Russian](${urlRu})`
153+
});
154+
console.log(`Updated comment ${commentId} with success status`);
155+
156+
- name: Update comment - deployment failed
157+
if: failure()
158+
uses: actions/github-script@v7
159+
with:
160+
github-token: ${{ secrets.GITHUB_TOKEN }}
161+
script: |
162+
const env = '${{ steps.env.outputs.env }}';
163+
const commentId = ${{ steps.comment.outputs.comment_id }};
164+
165+
// Get the job ID for the failed job
166+
const jobs = await github.rest.actions.listJobsForWorkflowRun({
167+
owner: context.repo.owner,
168+
repo: context.repo.repo,
169+
run_id: context.runId
170+
});
171+
172+
const job = jobs.data.jobs.find(j => j.name === 'deploy');
173+
const jobId = job ? job.id : null;
174+
175+
let logsUrl;
176+
if (jobId) {
177+
logsUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${jobId}`;
178+
} else {
179+
logsUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
180+
}
181+
182+
await github.rest.issues.updateComment({
183+
owner: context.repo.owner,
184+
repo: context.repo.repo,
185+
comment_id: commentId,
186+
body: `## ❌ Deployment Failed\n\n**Environment:** \`${env}\`\n\nPlease check the [workflow logs](${logsUrl}) for details.`
187+
});
188+
console.log(`Updated comment ${commentId} with failure status`);
189+
190+
- name: Remove deploy label
191+
if: always()
192+
uses: actions/github-script@v7
193+
with:
194+
github-token: ${{ secrets.GITHUB_TOKEN }}
195+
script: |
196+
const label = context.payload.label.name;
197+
if (label && (label === 'deploy/test' || label === 'deploy/stage')) {
198+
await github.rest.issues.removeLabel({
199+
owner: context.repo.owner,
200+
repo: context.repo.repo,
201+
issue_number: context.payload.pull_request.number,
202+
name: label
203+
});
204+
console.log(`Removed label: ${label}`);
205+
}
206+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint Markdown
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
lint-markdown:
8+
runs-on: ubuntu-latest
9+
name: Lint Markdown Files
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Run markdownlint
15+
run: make lint-markdown
16+
17+
- name: How to fix linting errors
18+
if: failure()
19+
run: |
20+
echo "::error::Markdown linting failed!"
21+
echo "To fix the errors automatically, run:"
22+
echo " make lint-markdown-fix"
23+
echo ""
24+
echo "Or fix them manually according to the errors shown above."
25+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHANGELOG/
2+
.werf/
3+
monitoring/
4+
node_modules/
5+
testing/
6+
tools/
7+
hooks/

0 commit comments

Comments
 (0)