Skip to content

Merge pull request #692 from okp4/dependabot/github_actions/tj-action… #272

Merge pull request #692 from okp4/dependabot/github_actions/tj-action…

Merge pull request #692 from okp4/dependabot/github_actions/tj-action… #272

name: Update chains description
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: update-chains-description-${{ github.ref }}
cancel-in-progress: true
jobs:
get-genesis:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
outputs:
matrix: ${{ steps.get-genesis.outputs.matrix }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find genesis files
id: get-genesis
run: |
files=""
for file in $(find . -name "genesis.json"); do
files="${files:+${files}, }\"${file}\""
done
echo "matrix={\"context\":[$files]}" >> "$GITHUB_OUTPUT"
generate-description:
name: Run Matrix Job
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
needs: [get-genesis]
strategy:
matrix: ${{ fromJSON(needs.get-genesis.outputs.matrix) }}
max-parallel: 1
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.OKP4_TOKEN }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.OKP4_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.OKP4_BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Install gomplate
run: |
curl -s -L -o /usr/local/bin/gomplate https://github.com/hairyhenderson/gomplate/releases/download/v3.11.3/gomplate_linux-amd64 &&
chmod +x /usr/local/bin/gomplate
- name: Generate template
run: |
genesis="${{ matrix.context }}"
path=$(dirname "$genesis")
usersInfo="${RUNNER_TEMP}$(uuidgen).json"
echo "{" >> "$usersInfo"
first="true"
for row in $(cat "$genesis" \
| jq -r '.app_state.genutil.gen_txs[].body.messages[].description.identity | select(. != "") | @base64'); do
userId=$(echo "$row" | base64 --decode)
echo "🪪 retrieve identity for $userId"
if [ "$first" = "true" ]; then
first="false"
else
echo "," >> "$usersInfo"
fi
echo "\"$userId\": " >> "$usersInfo"
curl --silent "https://keybase.io/_/api/1.0/user/user_search.json?q=${userId}&num_wanted=1" \
| jq ".list[0]" >> "$usersInfo"
done
echo "}" >> "$usersInfo"
echo "🖨 generate readme from $genesis"
gomplate -d genesis="$genesis" -d usersInfo="$usersInfo" -f "$path/README.md.gtpl" -o "$path/README.md"
- name: Add & Commit changes
uses: EndBug/add-and-commit@v9
with:
message: "docs(networks): update documentation (according to genesis)"
author_name: ${{ secrets.OKP4_BOT_GIT_AUTHOR_NAME }}
author_email: ${{ secrets.OKP4_BOT_GIT_AUTHOR_EMAIL }}
committer_name: ${{ secrets.OKP4_BOT_GIT_COMMITTER_NAME }}
committer_email: ${{ secrets.OKP4_BOT_GIT_COMMITTER_EMAIL }}
env:
GITHUB_TOKEN: ${{ secrets.OKP4_TOKEN }}