Skip to content

Commit f7e9ac3

Browse files
committed
wp.yml: try jus tbuild
1 parent 281b16a commit f7e9ac3

File tree

4 files changed

+79
-8
lines changed

4 files changed

+79
-8
lines changed

adminforth/build.log

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
> adminforth@1.6.0 build
3+
> rm -rf dist && tsc && npm run prepareDist && npm link
4+
5+
6+
> adminforth@1.6.0 prepareDist
7+
> cp -rL spa dist/
8+
9+
10+
up to date, audited 3 packages in 7s
11+
12+
found 0 vulnerabilities

adminforth/documentation/blog/2025-01-09-how-adminforth-manages-version/index.md

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ npm i -D semantic-release
113113

114114
We will use Woodpecker CI for this example. Woodpecker is a free and open-source CI/CD tool that you can install to your own server / VPS and will not need to pay only for server. No limits on pipelines, users, repositories, etc. If you want to try it, we have [Woodpecker installation guide](https://devforth.io/blog/step-by-step-guide-to-modern-secure-ci-setup/)
115115

116-
Create a file `.woodpecker.yml` in root of your repository:
116+
Create a file `.woodpecker.yml` in `deploy` directory:
117117

118-
```
118+
```yaml title="deploy/.woodpecker.yml"
119119
clone:
120120
git:
121121
image: woodpeckerci/plugin-git
@@ -257,7 +257,7 @@ git push
257257
This will trigger release `v1.2.0` because we merged `next` to `main` and it was a feature release.
258258
259259
260-
## Slack notifications
260+
## Slack notifications about releases
261261
262262
So now we have automatic releases with release notes on GitHub.
263263
For our internal team we use Slack and we want to get notifications about releases there.
@@ -294,8 +294,11 @@ Into "release" section of `package.json` add slack plugin:
294294
},
295295
//diff-add
296296
"markdownReleaseNotes": true
297+
//diff-add
297298
}
299+
//diff-add
298300
]
301+
//diff-add
299302
],
300303
```
301304
@@ -306,7 +309,7 @@ Add it to Woodpecker as secret `SLACK_WEBHOOK` environment variable.
306309
307310
Also add this secterd to `.woodpecker.yml`:
308311
309-
```
312+
```yaml title="deploy/.woodpecker.yml"
310313
secrets:
311314
- GITHUB_TOKEN
312315
- NPM_TOKEN
@@ -315,9 +318,64 @@ Also add this secterd to `.woodpecker.yml`:
315318
```
316319

317320

321+
318322
This will send notifications to Slack channel about succesfull releases when `npm run build` is done without errors.
319-
However if you have errors in build, or have unit tests in the flow, you will not get notifications about failed releases, because `npx semantic-release` will not be executed.
320323

321-
To fix it we will add another slack notification plugin, moreover we will use dedicated `adminforth-developers` channel for it.
324+
## Slack notifications about build errors and unhappen releases
325+
326+
327+
Create a file `failToSlack.sh` in `deploy` directory:
328+
329+
```sh title="deploy/failToSlack.sh"
330+
#!/bin/sh
331+
332+
export BUILD_LOG=$(cat ../../adminforth/build.log)
333+
334+
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
335+
336+
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)."
337+
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
338+
339+
curl -s -X POST -H "Content-Type: application/json" -d '{
340+
"username": "'"$CI_COMMIT_AUTHOR"'",
341+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
342+
"attachments": [
343+
{
344+
"mrkdwn_in": ["text", "pretext"],
345+
"color": "#8A1C12",
346+
"text": "'"$CODE_BLOCK"'",
347+
"pretext": "'"$MESSAGE"'"
348+
}
349+
]
350+
}' "$DEVELOPERS_SLACK_WEBHOOK"
351+
```
352+
353+
354+
Add `step` to `.woodpecker.yml`:
322355

356+
```yaml title="deploy/.woodpecker.yml"
357+
steps:
358+
release:
359+
...
360+
//diff-add
361+
slack-on-failure:
362+
//diff-add
363+
image: curlimages/curl
364+
//diff-add
365+
when:
366+
//diff-add
367+
- status: failure
368+
//diff-add
369+
event: push
370+
//diff-add
371+
- event: push
372+
//diff-add
373+
commands:
374+
//diff-add
375+
- cd deploy && /bin/sh failToSlack.sh
376+
//diff-add
377+
secrets:
378+
//diff-add
379+
- DEVELOPERS_SLACK_WEBHOOK
380+
323381
```

adminforth/documentation/src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const images = [
1414
original: require('@site/static/img/previews/login_form.png').default,
1515
title: 'Sign in form',
1616
link: '/docs/tutorial/gettingStarted',
17-
description: 'OWASP-Compliant Sign-In and JWT-SSO already there'
17+
description: 'OWASP-Compliant Sign-In already there'
1818
},
1919
{
2020
original: require('@site/static/img/previews/users_management.png').default,

live-demo/deploy/.woodpecker.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ steps:
1616
commands:
1717
- cd adminforth
1818
- npm clean-install
19-
- npm run build 2>&1 | tee build.log; [ $${PIPESTATUS[0]} -ne 0 ] && exit $${PIPESTATUS[0]}
19+
# - npm run build 2>&1 | tee build.log; [ $${PIPESTATUS[0]} -ne 0 ] && exit $${PIPESTATUS[0]}
20+
- npm run build
2021
- npm audit signatures
2122
- npx semantic-release
2223
secrets:

0 commit comments

Comments
 (0)