Skip to content

Adding chain support for Bitfinity Network Testnet #60

Adding chain support for Bitfinity Network Testnet

Adding chain support for Bitfinity Network Testnet #60

Workflow file for this run

on:
issues:
types: [opened]
jobs:
issue_commented:
name: Chain Support
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Run when issue is opened with specific label
if: ${{ contains(github.event.issue.labels.*.name, 'CHAIN_SUPPORT') }}
run: |
echo "Condition met"
- name: Check out repository
uses: actions/[email protected]
- name: Parse Issue
uses: stefanbuck/github-issue-praser@v3
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/chain-support.yml
- name: Save Parsed Issue as JSON
run: echo '${{ steps.issue-parser.outputs.jsonString }}' > input.json
- name: Update input.json
run: |
INPUT_JSON=$(cat input.json)
NAME=$(echo "$INPUT_JSON" | jq -r '.name')
FORMATTED_NAME=$(echo "$NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
ENVIRONMENT=$(echo "$INPUT_JSON" | jq -r '.environment')
LOWERCASE_ENVIRONMENT=$(echo "$ENVIRONMENT" | tr '[:upper:]' '[:lower:]')
if [ "$LOWERCASE_ENVIRONMENT" = "mainnet" ]; then
PRETTYNAME="$NAME"
else
PRETTYNAME="$NAME $ENVIRONMENT"
fi
LOWERCASE_PRETTY_NAME=$(echo "$PRETTYNAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
UPDATED_JSON=$(echo "$INPUT_JSON" | jq --arg formattedName "$FORMATTED_NAME" --arg prettyName "$PRETTYNAME" --arg lowercasePrettyName "$LOWERCASE_PRETTY_NAME" '. + { "lowercased_name": $formattedName, "prettyName": $prettyName, "lowercasePrettyName": $lowercasePrettyName }')
echo "$UPDATED_JSON" > input.json
- name: Cat input.json
run: |
cat input.json
- name: Setup Env
run: |
INPUT_JSON=$(cat input.json)
folderName="${{ steps.issue-parser.outputs.issueparser_name }}"
echo "folderName=$folderName" >> $GITHUB_ENV
lowercasePrettyName=$(echo "$INPUT_JSON" | jq -r '.lowercasePrettyName')
subFolderName="${lowercasePrettyName}-starter"
echo "subFolderName=$subFolderName" >> $GITHUB_ENV
- name: Create Issue Branch
env:
number: ${{ github.event.issue.number }}
title: ${{ github.event.issue.title }}
run: |
branchname=$number-$subFolderName
git switch -c "$branchname"
git config --global user.name 'github-actions'
git config --global user.email \
'41898282+github-actions[bot]@users.noreply.github.com'
git push -u origin "$branchname"
echo "branchname=$branchname" >> $GITHUB_ENV
- name: Make Changes to PR
run: |
echo $folderName
echo $subFolderName
cp -r .github/template .
cd template
mv template "$subFolderName"
cd ..
if [ -d "$folderName" ]; then
mv "template/$subFolderName" "$folderName/"
rm -rf template
else
mv template "$folderName"
fi
cd .github && yarn && cd ..
.github/node_modules/mustache/bin/mustache input.json .github/template/template/project.ts > "$folderName"/$subFolderName/project.ts
.github/node_modules/mustache/bin/mustache input.json .github/template/template/README.md > "$folderName"/$subFolderName/README.md
.github/node_modules/mustache/bin/mustache input.json .github/template/template/package.json > "$folderName"/$subFolderName/package.json
rm input.json
git add .
- name: Validate project
run: |
cd "$folderName/$subFolderName"
yarn && yarn codegen && yarn build
- name: Update PR workflow
run: |
file_path=".github/scripts/ci.package.json"
existing=$(jq '.workspaces | index("'"$folderName"'")' "$file_path")
if [ "$existing" == "null" ]; then
jq '.workspaces += ["'"$folderName"'"]' "$file_path" > "$file_path.tmp" && mv "$file_path.tmp" "$file_path"
fi
- name: Create PR
id: cpr
uses: peter-evans/create-pull-request@v6
env:
number: ${{ github.event.issue.number }}
NAME: ${{ steps.issue-parser.outputs.issueparser_name }}
with:
commit-message: Featuring ${{ steps.issue-parser.outputs.issueparser_name }}
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: ${{ env.branchname }}
base: main
delete-branch: true
title: "Featuring ${{ steps.issue-parser.outputs.issueparser_name }}"
body: |
Closes #${{ github.event.issue.number }}
draft: false