create-foliwake 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/files.js +15 -5
- package/package.json +3 -3
- package/starters/shared/README.md +37 -6
- package/starters/shared/_github/workflows/branch-preview.yml +50 -46
- package/starters/shared/_github/workflows/production.yml +41 -93
- package/starters/shared/tests/workflows.test.mjs +44 -21
- package/starters/shared/_github/actions/foliwake-request/action.yml +0 -45
- package/starters/shared/_github/scripts/foliwake-report.py +0 -68
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,36 @@ with them. While the version is 0.x, a minor release may break; breaking changes
|
|
|
5
5
|
|
|
6
6
|
Entries are written from the changesets of each pull request (`.changeset/`, CONTRIBUTING.md), newest first.
|
|
7
7
|
|
|
8
|
+
## 0.8.0
|
|
9
|
+
|
|
10
|
+
### Minor Changes
|
|
11
|
+
|
|
12
|
+
- 7e70573: The starter's GitHub workflows deploy with the open CLI instead of an SSH forced command: production runs
|
|
13
|
+
`npx @foliwake/cli@<version> code deploy`, branch previews `branch update` / `branch delete`, with the repository
|
|
14
|
+
variable `FOLIWAKE_SERVER` and the secret `FOLIWAKE_TOKEN` (a CI key from `foliwake account keys create --site`).
|
|
15
|
+
The CLI version is pinned exactly in the new project's `package.json` field `"foliwake": { "cli": "<version>" }`
|
|
16
|
+
(create's own release); the workflows read it and refuse anything but an exact version. It is not a
|
|
17
|
+
`devDependency`, so `npm install` never puts a `foliwake` into `node_modules/.bin` that would shadow the developer's
|
|
18
|
+
own CLI in `npm run dev`, `check:pages` or `stories` (install a CLI globally: `npm i -g @foliwake/cli`, or the
|
|
19
|
+
engine CLI). The README shows a Renovate custom regex manager that bumps the field. The SSH secrets, the
|
|
20
|
+
`foliwake-request` action and `foliwake-report.py` are gone, and so is the rollback workflow (a CI key cannot roll
|
|
21
|
+
back; an admin does it in the Foliwake admin or with `foliwake release rollback`).
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- @foliwake/block-kit@0.8.0
|
|
26
|
+
- @foliwake/site-check@0.8.0
|
|
27
|
+
|
|
28
|
+
## 0.7.0
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 214dd98: The `foliwake.config.json` of a new project names its content folder as a `local-markdown` source, the engine's
|
|
33
|
+
current format: the engine refuses the old `contentRoot` key, so `foliwake dev` and `page check` failed in a new
|
|
34
|
+
project with `SITE_CONFIG_INVALID`.
|
|
35
|
+
- @foliwake/block-kit@0.7.0
|
|
36
|
+
- @foliwake/site-check@0.7.0
|
|
37
|
+
|
|
8
38
|
## 0.6.0
|
|
9
39
|
|
|
10
40
|
### Patch Changes
|
package/dist/files.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// create-foliwake: the files of a new project, planned in memory from the starters (starters.ts). Nothing is
|
|
2
2
|
// downloaded: React comes vendored with this package, and the project has no npm dependencies unless it has
|
|
3
|
-
// Storybook.
|
|
3
|
+
// Storybook. The Foliwake CLI its CI workflows run is pinned in package.json `foliwake.cli`, not a dependency.
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { localSiteId, packageName } from './options.js';
|
|
6
6
|
import { layerFiles, packageVersion, projectPath, siteCheckVersion, starterFile, vendoredReact, } from './starters.js';
|
|
@@ -45,7 +45,7 @@ function localConfig(id) {
|
|
|
45
45
|
const site = {
|
|
46
46
|
id,
|
|
47
47
|
code: { root: '.', repository: null },
|
|
48
|
-
|
|
48
|
+
sources: [{ id: 'content', plugin: 'local-markdown', owns: ['/'], settings: { root: './content' } }],
|
|
49
49
|
storage: { endpoint: 'http://127.0.0.1:8333', bucket: `foliwake-${id}` },
|
|
50
50
|
stateDir: './.foliwake',
|
|
51
51
|
liveHosts: [`${id}.localhost`],
|
|
@@ -53,7 +53,15 @@ function localConfig(id) {
|
|
|
53
53
|
};
|
|
54
54
|
return `${JSON.stringify({ version: 1, sites: [site] }, null, 2)}\n`;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The Foliwake CLI the CI workflows run with npx: an exact version, the one of this package (the Foliwake packages
|
|
58
|
+
* are released together). It is a field of its own, not a devDependency: `npm run` puts node_modules/.bin first on
|
|
59
|
+
* PATH, and that `@foliwake/cli` (server commands only) would shadow the developer's `foliwake` in `npm run dev`.
|
|
60
|
+
*/
|
|
61
|
+
function foliwakeField(cliVersion) {
|
|
62
|
+
return { cli: cliVersion };
|
|
63
|
+
}
|
|
64
|
+
function packageJson(name, storybook, cliVersion) {
|
|
57
65
|
const stories = { stories: 'node .storybook/run.mjs', 'build-stories': 'foliwake blocks render && storybook build' };
|
|
58
66
|
const manifest = {
|
|
59
67
|
name,
|
|
@@ -67,13 +75,15 @@ function packageJson(name, storybook) {
|
|
|
67
75
|
'check:pages': 'foliwake page check',
|
|
68
76
|
...(storybook ? stories : {}),
|
|
69
77
|
},
|
|
78
|
+
foliwake: foliwakeField(cliVersion),
|
|
70
79
|
...(storybook ? { devDependencies: STORYBOOK_PACKAGES } : {}),
|
|
71
80
|
};
|
|
72
81
|
return `${JSON.stringify(manifest, null, 2)}\n`;
|
|
73
82
|
}
|
|
74
83
|
/** Every file of the new project, sorted by path. */
|
|
75
84
|
export async function projectFiles(input) {
|
|
76
|
-
const
|
|
85
|
+
const version = await packageVersion();
|
|
86
|
+
const values = placeholders(input, version, await siteCheckVersion());
|
|
77
87
|
const layers = [...TEMPLATE_LAYERS[input.template], ...(input.storybook ? ['storybook'] : [])];
|
|
78
88
|
if (input.react)
|
|
79
89
|
layers.push('react');
|
|
@@ -88,7 +98,7 @@ export async function projectFiles(input) {
|
|
|
88
98
|
for (const [file, bytes] of await vendoredReact())
|
|
89
99
|
files.set(file, bytes);
|
|
90
100
|
files.set(CONFIG_FILE_NAME, Buffer.from(localConfig(localSiteId(input.siteId, input.target))));
|
|
91
|
-
files.set('package.json', Buffer.from(packageJson(packageName(input.target), input.storybook ?? false)));
|
|
101
|
+
files.set('package.json', Buffer.from(packageJson(packageName(input.target), input.storybook ?? false, version)));
|
|
92
102
|
const sorted = [...files].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
93
103
|
return sorted.map(([file, bytes]) => ({ path: file, bytes }));
|
|
94
104
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-foliwake",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Create a Foliwake site frontend: npm create foliwake@latest. Blocks, styles, local sample pages, checks and GitHub workflows, checked with @foliwake/site-check before anything is written.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@clack/prompts": "1.8.1",
|
|
55
|
-
"@foliwake/block-kit": "0.
|
|
56
|
-
"@foliwake/site-check": "0.
|
|
55
|
+
"@foliwake/block-kit": "0.8.0",
|
|
56
|
+
"@foliwake/site-check": "0.8.0"
|
|
57
57
|
},
|
|
58
58
|
"files": [
|
|
59
59
|
"dist/",
|
|
@@ -84,20 +84,51 @@ With the repository connected to your site (below):
|
|
|
84
84
|
|
|
85
85
|
- **Push a branch** → the branch preview `https://<branch>--<site>.<branch host domain>/` shows the site's pages with that branch's code. Deleting the branch removes its preview.
|
|
86
86
|
- **Merge into `main`** → the checks run, the server prepares a code release from exactly that commit and rebuilds every page with it in the site's **preview**. Live does not change.
|
|
87
|
-
- **Release** → review the preview, then release it in the Foliwake admin: *Frontend → New code → Release*. A rollback is in the same place
|
|
87
|
+
- **Release** → review the preview, then release it in the Foliwake admin: *Frontend → New code → Release*. A rollback is in the same place (or `foliwake release rollback`, by an admin of the site).
|
|
88
88
|
|
|
89
89
|
## Connect to Foliwake
|
|
90
90
|
|
|
91
91
|
The workflows in `.github/workflows/` do nothing until the repository is connected. The "Frontend checks" workflow runs on every push and pull request from the start; it needs no secrets.
|
|
92
92
|
|
|
93
93
|
1. Push this repository to GitHub.
|
|
94
|
-
2. In the Foliwake admin, connect the repository to your site (or ask the operator of your Foliwake server to): it needs the clone URL
|
|
95
|
-
3.
|
|
96
|
-
|
|
97
|
-
- **
|
|
94
|
+
2. In the Foliwake admin, connect the repository to your site (or ask the operator of your Foliwake server to): it needs the clone URL (a private repository also needs a read token stored on the server) and gives you the **site id**{{siteIdNote}}.
|
|
95
|
+
3. Create a CI key of the site: `foliwake account keys create --site <site id> --server <server address>`. It can deploy code and update branch previews of this one site; it cannot publish pages or roll back.
|
|
96
|
+
4. In the GitHub repository settings:
|
|
97
|
+
- **Environments**: `branch-previews` and `production` (deployment branches: `main` only), each with the secret `FOLIWAKE_TOKEN` = the CI key.
|
|
98
|
+
- **Variables**: `FOLIWAKE_SERVER` = the server's address (e.g. `https://foliwake.example.com`); `FOLIWAKE_SITE_ID` = the site id; `BRANCH_PREVIEWS_ENABLED` = `true` to turn on branch previews; `FRONTEND_PRODUCTION_DEPLOY_ENABLED` = `true` to turn on main → preview → live (with the site setting `codeRelease: auto`, the default, a merge to main is released when every page builds without problems; with `manual` it waits for Release in the admin); optionally `FOLIWAKE_PREVIEW_URL` and `FOLIWAKE_PRODUCTION_URL` (shown as links in GitHub).
|
|
98
99
|
- **Branch protection** for `main`: require the "frontend-checks" status check.
|
|
99
100
|
|
|
100
|
-
Each variable switches on one workflow, so you can enable branch previews first and production later.
|
|
101
|
+
Each variable switches on one workflow, so you can enable branch previews first and production later.
|
|
102
|
+
|
|
103
|
+
### The CLI version of the workflows
|
|
104
|
+
|
|
105
|
+
The workflows run the open Foliwake CLI with `npx @foliwake/cli@<version>`, outside the checkout (so only `FOLIWAKE_SERVER` picks the server). The version is the exact one in the `foliwake.cli` field of `package.json`, set by create to its own release:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
"foliwake": { "cli": "{{createVersion}}" }
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Update it there; the workflows refuse anything but an exact version (`1.2.3`, no range). It is deliberately not a `devDependency`: `npm run` puts `node_modules/.bin` first on PATH, and an installed `@foliwake/cli` (server commands only, no local preview) would replace your own `foliwake` in `npm run dev` and `npm run check:pages`. On your machine, install a CLI globally instead: `npm i -g @foliwake/cli` for the server commands (`foliwake account keys create`, `branch update`, …), or the Foliwake CLI described in "Develop" for the local preview and page checks.
|
|
112
|
+
|
|
113
|
+
To let [Renovate](https://docs.renovatebot.com/) bump the field, add a custom manager to `renovate.json`:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
118
|
+
"customManagers": [
|
|
119
|
+
{
|
|
120
|
+
"customType": "regex",
|
|
121
|
+
"description": "The Foliwake CLI the workflows run: package.json foliwake.cli",
|
|
122
|
+
"managerFilePatterns": ["/(^|/)package\\.json$/"],
|
|
123
|
+
"matchStrings": ["\"foliwake\"\\s*:\\s*\\{[^}]*\"cli\"\\s*:\\s*\"(?<currentValue>[^\"]+)\""],
|
|
124
|
+
"depNameTemplate": "@foliwake/cli",
|
|
125
|
+
"datasourceTemplate": "npm"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
With `enabledManagers` set, add `"custom.regex"` to it.
|
|
101
132
|
|
|
102
133
|
## Content
|
|
103
134
|
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
# Hosted branch previews: every push to a branch other than main asks the
|
|
2
2
|
# Foliwake server to show exactly that commit as the branch preview
|
|
3
|
-
# https://<branch>--<site>[--<org>].<branch host domain
|
|
4
|
-
# the
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
3
|
+
# https://<branch>--<site>[--<org>].<branch host domain>/ (`foliwake branch
|
|
4
|
+
# update`): the branch's code over the site's saved preview content. Deleting
|
|
5
|
+
# the branch stops its preview (`foliwake branch delete`). Live and the site's
|
|
6
|
+
# preview are never touched; main is handled by production.yml. This site has
|
|
7
|
+
# no build step: the server takes the code (components/, scripts/, styles/,
|
|
8
|
+
# site.yaml) from the pushed commit itself.
|
|
9
9
|
#
|
|
10
10
|
# INERT until enabled: every job is skipped unless the repository variable
|
|
11
11
|
# BRANCH_PREVIEWS_ENABLED is `true` and FOLIWAKE_SITE_ID is set. How to enable
|
|
12
|
-
# it: README.md, "Connect to
|
|
12
|
+
# it: README.md, "Connect to Foliwake".
|
|
13
13
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
14
|
+
# Server and key: the repository variable FOLIWAKE_SERVER and the secret
|
|
15
|
+
# FOLIWAKE_TOKEN of the environment `branch-previews` (a CI key of this site,
|
|
16
|
+
# `foliwake account keys create --site <site>`; it cannot publish pages or roll
|
|
17
|
+
# back). The CLI is the open npm package @foliwake/cli, run with npx at the
|
|
18
|
+
# exact version pinned in package.json `foliwake.cli`, outside the checkout so
|
|
19
|
+
# only FOLIWAKE_SERVER picks the server. Pushes of forks never run here; pull
|
|
20
|
+
# requests are not a trigger.
|
|
19
21
|
#
|
|
20
22
|
# Ordering: cancelling an older run is only an optimisation. The server checks
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
+
# the run sequence (github.run_id), so a delayed older run never replaces a
|
|
24
|
+
# newer one.
|
|
23
25
|
name: Branch preview
|
|
24
26
|
on:
|
|
25
27
|
push:
|
|
@@ -45,28 +47,29 @@ jobs:
|
|
|
45
47
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
46
48
|
with:
|
|
47
49
|
persist-credentials: false
|
|
48
|
-
|
|
50
|
+
sparse-checkout: package.json
|
|
51
|
+
sparse-checkout-cone-mode: false
|
|
52
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
53
|
+
with:
|
|
54
|
+
node-version: '^22.22.0'
|
|
55
|
+
- name: The Foliwake CLI pinned in package.json foliwake.cli
|
|
56
|
+
id: cli
|
|
57
|
+
run: |
|
|
58
|
+
version=$(node -p "require('./package.json').foliwake?.cli")
|
|
59
|
+
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "package.json foliwake.cli must be an exact version of @foliwake/cli, not '$version'"; exit 1; }
|
|
60
|
+
echo "package=@foliwake/cli@$version" >> "$GITHUB_OUTPUT"
|
|
61
|
+
- name: Update the branch preview on the Foliwake server
|
|
62
|
+
working-directory: ${{ runner.temp }}
|
|
49
63
|
env:
|
|
64
|
+
FOLIWAKE_SERVER: ${{ vars.FOLIWAKE_SERVER }}
|
|
65
|
+
FOLIWAKE_TOKEN: ${{ secrets.FOLIWAKE_TOKEN }}
|
|
66
|
+
FOLIWAKE_CLI: ${{ steps.cli.outputs.package }}
|
|
50
67
|
BRANCH: ${{ github.ref_name }}
|
|
51
68
|
SHA: ${{ github.sha }}
|
|
52
69
|
RUN_ID: ${{ github.run_id }}
|
|
53
70
|
SITE: ${{ vars.FOLIWAKE_SITE_ID }}
|
|
54
71
|
run: |
|
|
55
|
-
|
|
56
|
-
- id: send
|
|
57
|
-
uses: ./.github/actions/foliwake-request
|
|
58
|
-
with:
|
|
59
|
-
command: branch-preview
|
|
60
|
-
request: ${{ runner.temp }}/request.json
|
|
61
|
-
ssh-key: ${{ secrets.BRANCH_PREVIEW_SSH_KEY }}
|
|
62
|
-
known-hosts: ${{ secrets.BRANCH_PREVIEW_KNOWN_HOSTS }}
|
|
63
|
-
target: ${{ secrets.BRANCH_PREVIEW_SSH_TARGET }}
|
|
64
|
-
- name: Report
|
|
65
|
-
env:
|
|
66
|
-
EXIT: ${{ steps.send.outputs.exit }}
|
|
67
|
-
run: |
|
|
68
|
-
python3 .github/scripts/foliwake-report.py branch-preview "$RUNNER_TEMP/foliwake-result.json"
|
|
69
|
-
test "$EXIT" = 0
|
|
72
|
+
npx --yes "$FOLIWAKE_CLI" branch update "$BRANCH" --site "$SITE" --rev "$SHA" --sequence "$RUN_ID" --json
|
|
70
73
|
delete:
|
|
71
74
|
if: >-
|
|
72
75
|
vars.BRANCH_PREVIEWS_ENABLED == 'true' &&
|
|
@@ -81,24 +84,25 @@ jobs:
|
|
|
81
84
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
82
85
|
with:
|
|
83
86
|
persist-credentials: false
|
|
84
|
-
|
|
87
|
+
sparse-checkout: package.json
|
|
88
|
+
sparse-checkout-cone-mode: false
|
|
89
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
90
|
+
with:
|
|
91
|
+
node-version: '^22.22.0'
|
|
92
|
+
- name: The Foliwake CLI pinned in package.json foliwake.cli
|
|
93
|
+
id: cli
|
|
94
|
+
run: |
|
|
95
|
+
version=$(node -p "require('./package.json').foliwake?.cli")
|
|
96
|
+
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "package.json foliwake.cli must be an exact version of @foliwake/cli, not '$version'"; exit 1; }
|
|
97
|
+
echo "package=@foliwake/cli@$version" >> "$GITHUB_OUTPUT"
|
|
98
|
+
- name: Stop the branch preview on the Foliwake server
|
|
99
|
+
working-directory: ${{ runner.temp }}
|
|
85
100
|
env:
|
|
101
|
+
FOLIWAKE_SERVER: ${{ vars.FOLIWAKE_SERVER }}
|
|
102
|
+
FOLIWAKE_TOKEN: ${{ secrets.FOLIWAKE_TOKEN }}
|
|
103
|
+
FOLIWAKE_CLI: ${{ steps.cli.outputs.package }}
|
|
86
104
|
BRANCH: ${{ github.event.ref }}
|
|
87
105
|
RUN_ID: ${{ github.run_id }}
|
|
88
106
|
SITE: ${{ vars.FOLIWAKE_SITE_ID }}
|
|
89
107
|
run: |
|
|
90
|
-
|
|
91
|
-
- id: send
|
|
92
|
-
uses: ./.github/actions/foliwake-request
|
|
93
|
-
with:
|
|
94
|
-
command: branch-preview
|
|
95
|
-
request: ${{ runner.temp }}/request.json
|
|
96
|
-
ssh-key: ${{ secrets.BRANCH_PREVIEW_SSH_KEY }}
|
|
97
|
-
known-hosts: ${{ secrets.BRANCH_PREVIEW_KNOWN_HOSTS }}
|
|
98
|
-
target: ${{ secrets.BRANCH_PREVIEW_SSH_TARGET }}
|
|
99
|
-
- name: Report
|
|
100
|
-
env:
|
|
101
|
-
EXIT: ${{ steps.send.outputs.exit }}
|
|
102
|
-
run: |
|
|
103
|
-
python3 .github/scripts/foliwake-report.py branch-preview "$RUNNER_TEMP/foliwake-result.json"
|
|
104
|
-
test "$EXIT" = 0
|
|
108
|
+
npx --yes "$FOLIWAKE_CLI" branch delete "$BRANCH" --site "$SITE" --sequence "$RUN_ID" --json
|
|
@@ -1,43 +1,35 @@
|
|
|
1
1
|
# Frontend production: a push to main (normally a merged pull request) runs the
|
|
2
|
-
# frontend checks and asks the Foliwake server to deploy exactly that commit
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
2
|
+
# frontend checks and asks the Foliwake server to deploy exactly that commit
|
|
3
|
+
# with `foliwake code deploy`: the server fetches the commit, makes a code
|
|
4
|
+
# release from it and rebuilds every page against it in the site's preview.
|
|
5
|
+
# With the site setting `codeRelease: auto` (the default) the server then
|
|
6
|
+
# checks the rebuild (every page built, no page with problems, the code fits
|
|
7
|
+
# the pages) and releases code and pages to live as one site release: merge to
|
|
8
|
+
# main = release. If a check fails, or the site uses `codeRelease: manual`, the
|
|
9
|
+
# code waits in the preview and you release it in the Foliwake admin
|
|
10
|
+
# (Frontend > New code > Release); live is unchanged.
|
|
10
11
|
# This site has no build step: the server takes the code from the main commit.
|
|
11
|
-
# Manual rollback (workflow_dispatch) makes an earlier site release live again,
|
|
12
|
-
# only while live is still the release you name as `expect`.
|
|
13
12
|
#
|
|
14
|
-
# Ordering: one run at a time (concurrency)
|
|
15
|
-
#
|
|
13
|
+
# Ordering: one run at a time (concurrency); the server refuses a deploy older
|
|
14
|
+
# than one it already prepared (--sequence is the run id).
|
|
16
15
|
#
|
|
17
|
-
# INERT until enabled: the deploy
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# README.md, "Connect to
|
|
16
|
+
# INERT until enabled: the deploy job is skipped unless the repository variable
|
|
17
|
+
# FRONTEND_PRODUCTION_DEPLOY_ENABLED is `true` (separate from
|
|
18
|
+
# BRANCH_PREVIEWS_ENABLED) and FOLIWAKE_SITE_ID is set. How to enable it:
|
|
19
|
+
# README.md, "Connect to Foliwake".
|
|
21
20
|
#
|
|
22
|
-
#
|
|
23
|
-
# secret
|
|
24
|
-
#
|
|
25
|
-
# site
|
|
21
|
+
# Server and key: the repository variable FOLIWAKE_SERVER (the server's address)
|
|
22
|
+
# and the secret FOLIWAKE_TOKEN (environment `production`, deployment branches:
|
|
23
|
+
# main only): a CI key of this site from `foliwake account keys create --site
|
|
24
|
+
# <site>`. It can deploy code and update branch previews; it cannot publish
|
|
25
|
+
# pages or roll back (an admin does that in the Foliwake admin or with
|
|
26
|
+
# `foliwake release rollback`). The CLI is the open npm package @foliwake/cli,
|
|
27
|
+
# run with npx at the exact version pinned in package.json `foliwake.cli`,
|
|
28
|
+
# outside the checkout so only FOLIWAKE_SERVER picks the server.
|
|
26
29
|
name: Frontend production
|
|
27
30
|
on:
|
|
28
31
|
push:
|
|
29
32
|
branches: [main]
|
|
30
|
-
workflow_dispatch:
|
|
31
|
-
inputs:
|
|
32
|
-
to:
|
|
33
|
-
description: 'Rollback target: "previous" (one site release back from live) or a site release sr_…'
|
|
34
|
-
required: true
|
|
35
|
-
default: previous
|
|
36
|
-
type: string
|
|
37
|
-
expect:
|
|
38
|
-
description: 'The live site release you saw (sr_…, from the Foliwake admin or `site status`); nothing changes if live is no longer it'
|
|
39
|
-
required: true
|
|
40
|
-
type: string
|
|
41
33
|
permissions:
|
|
42
34
|
contents: read
|
|
43
35
|
concurrency:
|
|
@@ -65,70 +57,26 @@ jobs:
|
|
|
65
57
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
66
58
|
with:
|
|
67
59
|
persist-credentials: false
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
RUN_ID: ${{ github.run_id }}
|
|
72
|
-
SITE: ${{ vars.FOLIWAKE_SITE_ID }}
|
|
73
|
-
run: |
|
|
74
|
-
python3 -c 'import json, os; print(json.dumps({"action": "deploy", "revision": os.environ["SHA"], "sequence": int(os.environ["RUN_ID"]), "site": os.environ["SITE"]}))' > "$RUNNER_TEMP/request.json"
|
|
75
|
-
- id: send
|
|
76
|
-
uses: ./.github/actions/foliwake-request
|
|
60
|
+
sparse-checkout: package.json
|
|
61
|
+
sparse-checkout-cone-mode: false
|
|
62
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
77
63
|
with:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
known-hosts: ${{ secrets.PRODUCTION_DEPLOY_KNOWN_HOSTS }}
|
|
82
|
-
target: ${{ secrets.PRODUCTION_DEPLOY_SSH_TARGET }}
|
|
83
|
-
- name: Report (fails unless released, prepared for a manual release, or superseded)
|
|
84
|
-
env:
|
|
85
|
-
EXIT: ${{ steps.send.outputs.exit }}
|
|
64
|
+
node-version: '^22.22.0'
|
|
65
|
+
- name: The Foliwake CLI pinned in package.json foliwake.cli
|
|
66
|
+
id: cli
|
|
86
67
|
run: |
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if: >-
|
|
93
|
-
github.event_name == 'workflow_dispatch' &&
|
|
94
|
-
github.ref == 'refs/heads/main' &&
|
|
95
|
-
vars.FRONTEND_PRODUCTION_DEPLOY_ENABLED == 'true' &&
|
|
96
|
-
vars.FOLIWAKE_SITE_ID != '' &&
|
|
97
|
-
!github.event.repository.fork
|
|
98
|
-
environment:
|
|
99
|
-
name: production
|
|
100
|
-
url: ${{ vars.FOLIWAKE_PRODUCTION_URL }}
|
|
101
|
-
runs-on: ubuntu-24.04
|
|
102
|
-
timeout-minutes: 20
|
|
103
|
-
steps:
|
|
104
|
-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
105
|
-
with:
|
|
106
|
-
persist-credentials: false
|
|
107
|
-
- name: Build the request (site releases only, with the live release you saw)
|
|
68
|
+
version=$(node -p "require('./package.json').foliwake?.cli")
|
|
69
|
+
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "package.json foliwake.cli must be an exact version of @foliwake/cli, not '$version'"; exit 1; }
|
|
70
|
+
echo "package=@foliwake/cli@$version" >> "$GITHUB_OUTPUT"
|
|
71
|
+
- name: Deploy on the Foliwake server
|
|
72
|
+
working-directory: ${{ runner.temp }}
|
|
108
73
|
env:
|
|
109
|
-
|
|
110
|
-
|
|
74
|
+
FOLIWAKE_SERVER: ${{ vars.FOLIWAKE_SERVER }}
|
|
75
|
+
FOLIWAKE_TOKEN: ${{ secrets.FOLIWAKE_TOKEN }}
|
|
76
|
+
FOLIWAKE_CLI: ${{ steps.cli.outputs.package }}
|
|
77
|
+
SHA: ${{ github.sha }}
|
|
78
|
+
RUN_ID: ${{ github.run_id }}
|
|
111
79
|
SITE: ${{ vars.FOLIWAKE_SITE_ID }}
|
|
112
80
|
run: |
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
to, expect = os.environ['TO'], os.environ['EXPECT']
|
|
116
|
-
if not (to == 'previous' or re.fullmatch(r'sr_[0-9a-f]{32}', to)) or not re.fullmatch(r'sr_[0-9a-f]{32}', expect):
|
|
117
|
-
sys.exit('to must be "previous" or sr_…, and expect the live sr_… you saw')
|
|
118
|
-
print(json.dumps({'action': 'rollback', 'to': to, 'expect': expect, 'site': os.environ['SITE']}))
|
|
119
|
-
PY
|
|
120
|
-
- id: send
|
|
121
|
-
uses: ./.github/actions/foliwake-request
|
|
122
|
-
with:
|
|
123
|
-
command: frontend-production
|
|
124
|
-
request: ${{ runner.temp }}/request.json
|
|
125
|
-
ssh-key: ${{ secrets.PRODUCTION_DEPLOY_SSH_KEY }}
|
|
126
|
-
known-hosts: ${{ secrets.PRODUCTION_DEPLOY_KNOWN_HOSTS }}
|
|
127
|
-
target: ${{ secrets.PRODUCTION_DEPLOY_SSH_TARGET }}
|
|
128
|
-
- name: Report (fails unless delivered or a no-op)
|
|
129
|
-
env:
|
|
130
|
-
EXIT: ${{ steps.send.outputs.exit }}
|
|
131
|
-
run: |
|
|
132
|
-
python3 .github/scripts/foliwake-report.py rollback "$RUNNER_TEMP/foliwake-result.json"
|
|
133
|
-
# 0: delivered / noop; 3: committed but the cache refresh is still pending; 1: refused or failed.
|
|
134
|
-
test "$EXIT" = 0
|
|
81
|
+
# 0: released (or prepared for a manual release); 3: released, cache refresh pending; 1: failed or held.
|
|
82
|
+
npx --yes "$FOLIWAKE_CLI" code deploy --site "$SITE" --rev "$SHA" --sequence "$RUN_ID" --json
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
// Static checks of the deployment workflows (run: node --test "tests/*.test.mjs"). They pin
|
|
2
2
|
// down what keeps them safe: both deployment workflows stay inert until their
|
|
3
3
|
// own repository variable is `true`, branch previews and production use
|
|
4
|
-
// separate environments
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// separate environments, production runs only from main after the checks,
|
|
5
|
+
// nothing with secrets runs for pull requests or forks, the only secret is the
|
|
6
|
+
// CI key FOLIWAKE_TOKEN, the CLI is the version pinned in package.json
|
|
7
|
+
// `foliwake.cli` (not a dependency), run outside the checkout, and every
|
|
8
|
+
// action is pinned to a commit SHA.
|
|
9
|
+
// Text-based (no YAML dependency).
|
|
7
10
|
import assert from 'node:assert/strict';
|
|
8
11
|
import { readFileSync } from 'node:fs';
|
|
9
12
|
import { test } from 'node:test';
|
|
10
13
|
|
|
11
14
|
const read = (name) => readFileSync(new URL(`../.github/workflows/${name}`, import.meta.url), 'utf8');
|
|
15
|
+
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
12
16
|
const files = { checks: read('frontend-checks.yml'), preview: read('branch-preview.yml'), production: read('production.yml') };
|
|
13
17
|
|
|
14
18
|
// Job blocks: ` <id>:` lines directly under `jobs:`.
|
|
@@ -44,7 +48,27 @@ test('frontend checks use no secrets (safe for fork pull requests) and run the t
|
|
|
44
48
|
assert.match(files.checks, /node --test "tests\/\*\.test\.mjs"/);
|
|
45
49
|
});
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
/** A job that calls the server: the pinned CLI, outside the checkout, with the server and key from GitHub. */
|
|
52
|
+
function assertServerCall(job, id, command) {
|
|
53
|
+
const pick = /version=\$\(node -p "require\('\.\/package\.json'\)\.foliwake\?\.cli"\)\n/;
|
|
54
|
+
assert.match(job, pick, `${id}: the CLI version comes from package.json foliwake.cli`);
|
|
55
|
+
assert.match(job, /\^\[0-9\]\+\\\.\[0-9\]\+\\\.\[0-9\]\+\$/, `${id}: an exact version only`);
|
|
56
|
+
assert.match(job, new RegExp(`npx --yes "\\$FOLIWAKE_CLI" ${command} .*--site "\\$SITE" .*--json`), `${id}: ${command}`);
|
|
57
|
+
assert.match(job, /working-directory: \$\{\{ runner\.temp \}\}/, `${id}: runs outside the checkout`);
|
|
58
|
+
assert.match(job, /FOLIWAKE_SERVER: \$\{\{ vars\.FOLIWAKE_SERVER \}\}/, `${id}: the server is a variable`);
|
|
59
|
+
assert.match(job, /RUN_ID/, `${id}: ordering sequence from the run id`);
|
|
60
|
+
for (const [, secret] of job.matchAll(/secrets\.([A-Z0-9_]+)/g)) assert.equal(secret, 'FOLIWAKE_TOKEN', `${id}: ${secret}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
test('the project pins the Foliwake CLI the workflows run, exactly, outside its dependencies', () => {
|
|
64
|
+
assert.match(manifest.foliwake?.cli ?? '', /^[0-9]+\.[0-9]+\.[0-9]+$/);
|
|
65
|
+
// A dependency would put its `foliwake` (server commands only) first on `npm run`'s PATH.
|
|
66
|
+
for (const deps of [manifest.dependencies, manifest.devDependencies]) {
|
|
67
|
+
assert.equal(deps?.['@foliwake/cli'], undefined, '@foliwake/cli is not a dependency');
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('branch previews: inert until BRANCH_PREVIEWS_ENABLED, own environment, never main', () => {
|
|
48
72
|
const text = files.preview;
|
|
49
73
|
assert.match(text, /^ push:\n branches-ignore: \[main\]\n delete:\n/m);
|
|
50
74
|
assert.doesNotMatch(text, /workflow_dispatch|pull_request/);
|
|
@@ -57,28 +81,27 @@ test('branch previews: inert until BRANCH_PREVIEWS_ENABLED, own environment and
|
|
|
57
81
|
assert.match(job, /!github\.event\.repository\.fork/, `${id}: not in forks`);
|
|
58
82
|
assert.match(job, /(github\.ref_name|github\.event\.ref) != 'main'/, `${id}: never main`);
|
|
59
83
|
assert.match(job, /^ environment: branch-previews$/m, `${id}: environment`);
|
|
60
|
-
for (const [, secret] of job.matchAll(/secrets\.([A-Z0-9_]+)/g)) assert.match(secret, /^BRANCH_PREVIEW_/, `${id}: ${secret}`);
|
|
61
|
-
assert.match(job, /RUN_ID/, `${id}: ordering sequence from the run id`);
|
|
62
84
|
}
|
|
85
|
+
assertServerCall(all.preview, 'preview', 'branch update "\\$BRANCH"');
|
|
86
|
+
assertServerCall(all.delete, 'delete', 'branch delete "\\$BRANCH"');
|
|
63
87
|
});
|
|
64
88
|
|
|
65
|
-
test('production: inert until FRONTEND_PRODUCTION_DEPLOY_ENABLED, main only, after the checks,
|
|
89
|
+
test('production: inert until FRONTEND_PRODUCTION_DEPLOY_ENABLED, main only, after the checks, deploy only', () => {
|
|
66
90
|
const text = files.production;
|
|
67
91
|
assert.match(text, /^ push:\n branches: \[main\]\n/m);
|
|
68
|
-
assert.doesNotMatch(text, /
|
|
92
|
+
assert.doesNotMatch(text, /workflow_dispatch/, 'no rollback from CI: a CI key cannot roll back');
|
|
69
93
|
const all = jobs(text);
|
|
94
|
+
assert.deepEqual(Object.keys(all).sort(), ['checks', 'deploy']);
|
|
70
95
|
assert.match(all.checks, /uses: \.\/\.github\/workflows\/frontend-checks\.yml/);
|
|
71
|
-
|
|
72
|
-
assert.match(
|
|
73
|
-
assert.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
assert.match(all.rollback, /expect/, 'a rollback names the live release it expects');
|
|
96
|
+
const job = all.deploy;
|
|
97
|
+
assert.match(job, /^ needs: checks$/m, 'deploy needs the checks');
|
|
98
|
+
assert.match(job, /vars\.FRONTEND_PRODUCTION_DEPLOY_ENABLED == 'true'/, 'own enablement guard');
|
|
99
|
+
assert.doesNotMatch(job, /BRANCH_PREVIEWS_ENABLED/, 'not the branch-preview guard');
|
|
100
|
+
assert.match(job, /github\.ref == 'refs\/heads\/main'/, 'main only');
|
|
101
|
+
assert.match(job, /!github\.event\.repository\.fork/, 'not in forks');
|
|
102
|
+
assert.match(job, /^ environment:\n name: production$/m, 'production environment');
|
|
103
|
+
assertServerCall(job, 'deploy', 'code deploy');
|
|
104
|
+
assert.match(job, /--rev "\$SHA"/, 'exactly the pushed commit');
|
|
105
|
+
const steps = Object.values(all).join('');
|
|
106
|
+
assert.doesNotMatch(steps, /release rollback|promote/, 'only the server decides a release, for the commit it deployed');
|
|
84
107
|
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# One request to a Foliwake forced command over SSH: the request travels on stdin only, the key
|
|
2
|
-
# and known hosts exist only for this step (removed on exit), the JSON answer is left at
|
|
3
|
-
# $RUNNER_TEMP/foliwake-result.json. Used by production.yml and branch-preview.yml.
|
|
4
|
-
name: Foliwake request
|
|
5
|
-
description: Send one JSON request to a Foliwake forced command over SSH
|
|
6
|
-
inputs:
|
|
7
|
-
command:
|
|
8
|
-
description: 'frontend-production or branch-preview (ignored by the forced command; names the key in logs)'
|
|
9
|
-
required: true
|
|
10
|
-
request:
|
|
11
|
-
description: Path of the JSON request file
|
|
12
|
-
required: true
|
|
13
|
-
ssh-key:
|
|
14
|
-
required: true
|
|
15
|
-
known-hosts:
|
|
16
|
-
required: true
|
|
17
|
-
target:
|
|
18
|
-
required: true
|
|
19
|
-
outputs:
|
|
20
|
-
exit:
|
|
21
|
-
description: Exit status of the forced command (0 done, 1 refused or failed, 3 committed with a pending cache refresh)
|
|
22
|
-
value: ${{ steps.send.outputs.exit }}
|
|
23
|
-
runs:
|
|
24
|
-
using: composite
|
|
25
|
-
steps:
|
|
26
|
-
- id: send
|
|
27
|
-
shell: bash
|
|
28
|
-
env:
|
|
29
|
-
SSH_KEY: ${{ inputs.ssh-key }}
|
|
30
|
-
KNOWN_HOSTS: ${{ inputs.known-hosts }}
|
|
31
|
-
TARGET: ${{ inputs.target }}
|
|
32
|
-
COMMAND: ${{ inputs.command }}
|
|
33
|
-
REQUEST: ${{ inputs.request }}
|
|
34
|
-
run: |
|
|
35
|
-
set +e
|
|
36
|
-
material=$(mktemp -d)
|
|
37
|
-
trap 'rm -rf "$material"' EXIT
|
|
38
|
-
printf '%s\n' "$SSH_KEY" > "$material/key"
|
|
39
|
-
printf '%s\n' "$KNOWN_HOSTS" > "$material/known_hosts"
|
|
40
|
-
chmod 600 "$material/key" "$material/known_hosts"
|
|
41
|
-
cat "$REQUEST"
|
|
42
|
-
ssh -o BatchMode=yes -o StrictHostKeyChecking=yes -o IdentitiesOnly=yes -o UserKnownHostsFile="$material/known_hosts" -i "$material/key" "$TARGET" "$COMMAND" \
|
|
43
|
-
< "$REQUEST" > "$RUNNER_TEMP/foliwake-result.json"
|
|
44
|
-
echo "exit=$?" >> "$GITHUB_OUTPUT"
|
|
45
|
-
cat "$RUNNER_TEMP/foliwake-result.json"
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Job summary and step outputs for the answer of a Foliwake forced command.
|
|
3
|
-
|
|
4
|
-
Usage: foliwake-report.py <production|rollback|branch-preview> <result.json>
|
|
5
|
-
Outputs (GITHUB_OUTPUT): state (the result or state field), url, revision.
|
|
6
|
-
"""
|
|
7
|
-
import json, os, sys
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def seconds(ms):
|
|
11
|
-
return f'{ms / 1000:.1f} s' if isinstance(ms, (int, float)) else '?'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def timing_lines(t):
|
|
15
|
-
"""Where a deploy's time went (its answer's `timings`): the total, then each step with its store requests."""
|
|
16
|
-
if not isinstance(t, dict) or not isinstance(t.get('steps'), dict):
|
|
17
|
-
return []
|
|
18
|
-
store = t.get('store') if isinstance(t.get('store'), dict) else {}
|
|
19
|
-
per_step = t.get('stepStore') if isinstance(t.get('stepStore'), dict) else {}
|
|
20
|
-
out = [f"- took: `{seconds(t.get('totalMs'))}`; pages built: `{t.get('pagesBuilt')}`; store requests: `{store.get('requests')}`", '',
|
|
21
|
-
'| step | time | store requests |', '| --- | ---: | ---: |']
|
|
22
|
-
for step, ms in t['steps'].items():
|
|
23
|
-
requests = per_step.get(step, {}).get('requests') if isinstance(per_step.get(step), dict) else None
|
|
24
|
-
out.append(f"| {step} | {seconds(ms)} | {'' if requests is None else requests} |")
|
|
25
|
-
return out
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
kind, path = sys.argv[1], sys.argv[2]
|
|
29
|
-
try:
|
|
30
|
-
r = json.load(open(path))
|
|
31
|
-
except (OSError, ValueError):
|
|
32
|
-
r = {'result': 'failed', 'state': 'failed', 'message': 'no JSON answer from the server'}
|
|
33
|
-
|
|
34
|
-
state = r.get('result') or r.get('state') or 'failed'
|
|
35
|
-
with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
|
|
36
|
-
out.write(f"state={state}\nurl={r.get('url') or ''}\nrevision={r.get('revision') or r.get('mainCommit') or ''}\n")
|
|
37
|
-
|
|
38
|
-
if kind == 'branch-preview':
|
|
39
|
-
lines = [f"### Branch preview: {r.get('branch', '')}", '', f'- state: `{state}`']
|
|
40
|
-
if r.get('url'):
|
|
41
|
-
lines.append(f"- URL: {r['url']} (owner Basic auth)")
|
|
42
|
-
rows = [('build commit', r.get('revision')), ('code release', r.get('codeRelease'))]
|
|
43
|
-
else:
|
|
44
|
-
title = 'Frontend production' if kind == 'production' else 'Frontend rollback'
|
|
45
|
-
refresh = r.get('cacheRefresh') or {}
|
|
46
|
-
rows = [('action', r.get('action')), ('commit', r.get('sourceCommit') or r.get('mainCommit')), ('built commit', r.get('mainCommit')),
|
|
47
|
-
('code release', r.get('codeRelease')), ('preview release', r.get('previewRelease')), ('release with', r.get('expect')),
|
|
48
|
-
('live release' if kind == 'production' else 'to', r.get('siteRelease')), ('live before', r.get('previousSiteRelease')), ('result', state),
|
|
49
|
-
('code release mode', r.get('mode')), ('code', r.get('code')), ('operation', r.get('operation')),
|
|
50
|
-
('cache refresh', refresh.get('state')), ('delivered', r.get('delivered') if kind == 'rollback' or state == 'released' else None), ('record', r.get('record'))]
|
|
51
|
-
lines = [f'### {title}', '']
|
|
52
|
-
if state == 'released':
|
|
53
|
-
rows.append(('next', 'nothing: code and pages are live as one site release; roll back with a manual run of this workflow if needed'))
|
|
54
|
-
elif state == 'prepared' and r.get('held'):
|
|
55
|
-
rows.append(('next', 'the automatic release was held (see the checks below); live is unchanged. Fix it and push again, or review and Release in the Foliwake admin'))
|
|
56
|
-
elif state == 'prepared':
|
|
57
|
-
rows.append(('next', 'review the preview, then Release in the Foliwake admin; live is unchanged'))
|
|
58
|
-
lines += [f'- {k}: `{v}`' for k, v in rows if v is not None]
|
|
59
|
-
lines += timing_lines(r.get('timings'))
|
|
60
|
-
for g in (r.get('gates') or []):
|
|
61
|
-
if isinstance(g, dict):
|
|
62
|
-
lines.append(f" - check {g.get('gate')}: {'ok' if g.get('ok') else 'FAILED'} — {g.get('detail')}")
|
|
63
|
-
for d in (r.get('diagnostics') or [])[:20]:
|
|
64
|
-
lines.append(f" - {d.get('file')}:{d.get('line')} {d.get('code')}: {d.get('message')}")
|
|
65
|
-
if r.get('message'):
|
|
66
|
-
lines.append(f"- {r['message']}")
|
|
67
|
-
with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as summary:
|
|
68
|
-
summary.write('\n'.join(lines) + '\n')
|