Skip to content

Commit 6cc237c

Browse files
fix: address PR comments from #211 (#224)
Signed-off-by: Jeromy Cannon <[email protected]> Signed-off-by: Swirlds Automation <[email protected]> Co-authored-by: Swirlds Automation <[email protected]>
1 parent fe865f8 commit 6cc237c

File tree

4 files changed

+37
-32
lines changed

4 files changed

+37
-32
lines changed

.github/workflows/flow-update-readme.yaml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,28 @@
1717
name: Update README.md
1818
on:
1919
workflow_dispatch:
20-
pull_request:
21-
types:
22-
- opened
23-
- reopened
24-
- synchronize
20+
push:
21+
branches:
22+
- main
2523
paths:
2624
- '**/*.mjs'
2725
- '**/*.js'
2826
- '**/package*.json'
27+
- '**/README.md.template'
2928
defaults:
3029
run:
3130
shell: bash
31+
permissions:
32+
contents: read
3233
jobs:
3334
update:
3435
runs-on: [self-hosted, Linux, medium, ephemeral]
35-
permissions:
36-
# Give the default GITHUB_TOKEN write permission to commit and push the
37-
# added or changed files to the repository.
38-
contents: write
3936
steps:
4037
- name: Checkout Code for Push
4138
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
42-
if: github.event_name == 'push'
4339
with:
4440
fetch-depth: 0
45-
46-
# https://github.com/actions/checkout/issues/124
47-
- name: Checkout Code for Pull Request
48-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
49-
if: github.event_name == 'pull_request'
50-
with:
51-
fetch-depth: 0
52-
ref: ${{ github.event.pull_request.head.ref }}
41+
token: ${{secrets.GH_ACCESS_TOKEN}}
5342

5443
- name: Setup Node
5544
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
@@ -86,13 +75,14 @@ jobs:
8675
8776
- name: Update README.md
8877
run: |
78+
set -x
8979
npm install -g @hashgraph/solo
9080
which solo
9181
9282
export SOLO_CLUSTER_NAME=solo
9383
export SOLO_NAMESPACE=solo
9484
export SOLO_CLUSTER_SETUP_NAMESPACE=solo-cluster
95-
85+
9686
echo "Perform the following kind and solo commands and save output to environment variables"
9787
9888
export KIND_CREATE_CLUSTER_OUTPUT=$( kind create cluster -n "${SOLO_CLUSTER_NAME}" 2>&1 | tee test.log )
@@ -133,6 +123,7 @@ jobs:
133123
sed -i 's/\[33m//g' README.md
134124
sed -i 's/\[39m//g' README.md
135125
egrep -v '↓|❯|•' README.md > README.md.tmp && mv README.md.tmp README.md
126+
set +x
136127
137128
- name: Check README.md Changes
138129
id: check-readme-changes
@@ -145,7 +136,7 @@ jobs:
145136
146137
DELETIONS=$(echo $CHANGES | grep -o '[0-9]\+' | tail -1)
147138
echo "Deletions: $DELETIONS"
148-
139+
149140
# Calculate total lines changed if INSERTIONS and DELETIONS are not empty
150141
if [ -z "$INSERTIONS" ]; then
151142
INSERTIONS=0
@@ -156,15 +147,24 @@ jobs:
156147
157148
TOTAL_LINES_CHANGED=$(($INSERTIONS + $DELETIONS))
158149
echo "Total README lines changed: $TOTAL_LINES_CHANGED"
159-
echo "TOTAL_LINES_CHANGED=$TOTAL_LINES_CHANGED" >> "${GITHUB_OUTPUT}"
160150
161-
# Signed Commits by actions https://github.com/actions/runner/issues/667
151+
- name: Import GPG key
152+
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
153+
with:
154+
gpg_private_key: ${{ secrets.GH_ACCESS_GPG_KEY }}
155+
passphrase: ${{ secrets.GH_ACCESS_PASSPHRASE }}
156+
git_user_signingkey: true
157+
git_commit_gpgsign: true
158+
162159
- name: Commit README.md Changes
163-
if: ${{ steps.check-readme-changes.outputs.TOTAL_LINES_CHANGED > 20 }}
164-
uses: planetscale/[email protected]
160+
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
165161
with:
166-
commit_message: "auto update README.md"
167-
repo: ${{ github.repository }}
168-
branch: ${{ github.head_ref || github.ref_name }}
162+
commit_message: "auto update README.md [skip ci]"
163+
commit_options: '--no-verify --signoff'
164+
add_options: '-u'
165+
file_pattern: 'README.md'
166+
commit_user_name: Swirlds Automation
167+
commit_user_email: [email protected]
168+
commit_author: Swirlds Automation <[email protected]>
169169
env:
170-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
170+
GITHUB_TOKEN: ${{secrets.GH_ACCESS_TOKEN}}

README.md.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ $ rm -rf ~/.solo
291291
$ solo init -t v0.47.0-alpha.0 -i node0,node1,node2 -n "${SOLO_NAMESPACE}" -s "${SOLO_CLUSTER_SETUP_NAMESPACE}" --key-format pem
292292
```
293293

294-
* Example output:
294+
* Example output
295295

296296
```
297297
$SOLO_INIT_047_OUTPUT
@@ -303,7 +303,7 @@ $SOLO_INIT_047_OUTPUT
303303
$ solo node keys --gossip-keys --tls-keys --key-format pem
304304
```
305305

306-
* Example output:
306+
* Example output
307307

308308
```
309309
$SOLO_NODE_KEY_PEM_OUTPUT

src/commands/node.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ export class NodeCommand extends BaseCommand {
955955
force: self.configManager.getFlag(flags.force),
956956
applicationEnv: self.configManager.getFlag(flags.applicationEnv),
957957
keyFormat: self.configManager.getFlag(flags.keyFormat),
958-
de3vMode: self.configManager.getFlag(flags.devMode),
958+
devMode: self.configManager.getFlag(flags.devMode),
959959
curDate: new Date()
960960
}
961961

@@ -1239,7 +1239,7 @@ export class NodeCommand extends BaseCommand {
12391239
})
12401240
.command({
12411241
command: 'refresh',
1242-
desc: 'Refresh a node',
1242+
desc: 'Reset and restart a node',
12431243
builder: y => flags.setCommandFlags(y,
12441244
flags.namespace,
12451245
flags.nodeIDs,

src/core/helpers.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ export function isNumeric (str) {
171171
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
172172
}
173173

174+
/**
175+
* Validate a path provided by the user to prevent path traversal attacks
176+
* @param input the input provided by the user
177+
* @returns {*} a validated path
178+
*/
174179
export function validatePath (input) {
175180
if (input.indexOf('\0') !== -1) {
176181
throw new FullstackTestingError(`access denied for path: ${input}`)

0 commit comments

Comments
 (0)