-
Notifications
You must be signed in to change notification settings - Fork 8
154 lines (137 loc) · 4.94 KB
/
zxc-update-readme.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
##
# Copyright (C) 2023-2024 Hedera Hashgraph, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
name: Update README.md
on:
workflow_dispatch:
workflow_call:
secrets:
GH_ACCESS_TOKEN:
description: "GitHub Access Token"
required: true
GH_ACCESS_GPG_KEY:
description: "GitHub Access GPG Key"
required: true
GH_ACCESS_PASSPHRASE:
description: "GitHub Access Passphrase"
required: true
inputs:
commit-changes:
description: "Commit updated README.md"
type: boolean
required: false
default: false
version:
description: "The version to set the app to during deploy/release"
type: string
required: false
outputs:
commit-hash:
description: "The commit hash for the updated README.md commit"
value: ${{ jobs.update.outputs.commit_hash }}
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
update:
outputs:
commit_hash: ${{ steps.commit-readme.outputs.commit_hash }}
runs-on: solo-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Checkout Code for Push
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
- name: Install wget
run: |
sudo apt-get update
sudo apt-get install -y wget
- name: Setup Kind
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
install_only: true
node_image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
version: v0.21.0
kubectl_version: v1.28.6
verbosity: 3
wait: 120s
- name: Install gettext-base
id: gettext-base
run: |
sudo apt-get update
sudo apt-get install gettext-base
- name: Update README.md
run: |
set -xeo pipefail
npm install
npm run build
npm install -g @hashgraph/solo
npm link
echo "VERSION=${{ inputs.version }}"
[[ -n "${{ inputs.version }}" ]] && npm version ${{ inputs.version }} -f --no-git-tag-version
which solo
node -p -e "Boolean(process.stdout.isTTY)"
chmod 755 ./.github/workflows/script/update_md.sh
./.github/workflows/script/update_md.sh </dev/null | cat
set +x
- name: Check README.md Changes
id: check-readme-changes
run: |
CHANGES=$(git diff --stat)
echo "Changes: $CHANGES"
INSERTIONS=$(echo $CHANGES | grep -o -P '(?<=insertions\(\+\), )\d+')
echo "Insertions: $INSERTIONS"
DELETIONS=$(echo $CHANGES | grep -o '[0-9]\+' | tail -1)
echo "Deletions: $DELETIONS"
# Calculate total lines changed if INSERTIONS and DELETIONS are not empty
if [ -z "$INSERTIONS" ]; then
INSERTIONS=0
fi
if [ -z "$DELETIONS" ]; then
DELETIONS=0
fi
TOTAL_LINES_CHANGED=$(($INSERTIONS + $DELETIONS))
echo "Total README lines changed: $TOTAL_LINES_CHANGED"
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
with:
gpg_private_key: ${{ secrets.GH_ACCESS_GPG_KEY }}
passphrase: ${{ secrets.GH_ACCESS_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit README.md Changes
id: commit-readme
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
with:
commit_message: "auto update README.md [skip ci]"
commit_options: '--no-verify --signoff'
add_options: '-u'
file_pattern: 'README.md'
commit_user_name: Swirlds Automation
commit_user_email: [email protected]
commit_author: Swirlds Automation <[email protected]>
env:
GITHUB_TOKEN: ${{secrets.GH_ACCESS_TOKEN}}