Skip to content

fix: rename flag

fix: rename flag #502

##
# 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_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 }}
push:
paths:
- '**/*.mjs'
- '**/*.js'
- '**/package*.json'
- '**/README.md.template'
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: Checkout Code for Push
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Setup Node with Retry
uses: Wandalen/wretry.action@6feedb7dedadeb826de0f45ff482b53b379a7844 # v3.5.0
with:
action: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with: |
node-version: 20.14.0
cache: npm
attempt_limit: 3
attempt_delay: 5000
- 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 NVM & Dependencies
id: npm-deps
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install lts/hydrogen
nvm use lts/hydrogen
npm ci
- name: Install gettext-base
id: gettext-base
run: |
sudo apt-get update
sudo apt-get install gettext-base
- name: Update README.md
run: |
set -x
npm install
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
export SOLO_CLUSTER_NAME=solo
export SOLO_NAMESPACE=solo
export SOLO_CLUSTER_SETUP_NAMESPACE=solo-cluster
echo "Perform the following kind and solo commands and save output to environment variables"
export KIND_CREATE_CLUSTER_OUTPUT=$( kind create cluster -n "${SOLO_CLUSTER_NAME}" 2>&1 | tee test.log )
export SOLO_INIT_OUTPUT=$( solo init -i node1,node2,node3 -n "${SOLO_NAMESPACE}" -s \
"${SOLO_CLUSTER_SETUP_NAMESPACE}" | tee test.log )
export SOLO_NODE_KEY_PEM_OUTPUT=$( solo node keys --gossip-keys --tls-keys | tee test.log )
export SOLO_CLUSTER_SETUP_OUTPUT=$( solo cluster setup | tee test.log )
export SOLO_NETWORK_DEPLOY_OUTPUT=$( solo network deploy | tee test.log )
export SOLO_NODE_SETUP_OUTPUT=$( solo node setup | tee test.log )
export SOLO_NODE_START_OUTPUT=$( solo node start | tee test.log )
export SOLO_MIRROR_NODE_DEPLOY_OUTPUT=$( solo mirror-node deploy | tee test.log )
export SOLO_RELAY_DEPLAY_OUTPUT=$( solo relay deploy -i node1,node2 | tee test.log )
export SOLO_RELAY_DEPLOY_OUTPUT=$( solo relay deploy | tee test.log )
echo "Generate README.md"
envsubst '$KIND_CREATE_CLUSTER_OUTPUT,$SOLO_INIT_OUTPUT,$SOLO_NODE_KEY_PEM_OUTPUT,$SOLO_CLUSTER_SETUP_OUTPUT, \
$SOLO_NETWORK_DEPLOY_OUTPUT,$SOLO_NODE_SETUP_OUTPUT,$SOLO_NODE_START_OUTPUT,$SOLO_MIRROR_NODE_DEPLOY_OUTPUT,\
$SOLO_RELAY_DEPLAY_OUTPUT,$SOLO_RELAY_DEPLOY_OUTPUT'\
< README.md.template > README.md
echo "Remove color codes and lines showing intermediate progress"
sed -i 's/\[32m//g' README.md
sed -i 's/\[33m//g' README.md
sed -i 's/\[39m//g' README.md
egrep -v '↓|❯|•' README.md > README.md.tmp && mv README.md.tmp README.md
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@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.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
if : ${{ github.event.inputs.dry-run-enabled != 'true' && !cancelled() && !failure() && inputs.commit-changes }}
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: swirlds-eng-automation@swirlds.com
commit_author: Swirlds Automation <swirlds-eng-automation@swirlds.com>
env:
GITHUB_TOKEN: ${{secrets.GH_ACCESS_TOKEN}}