Skip to content

Commit

Permalink
Merge pull request #453 from JJ-Cro/ReadmeUpdate
Browse files Browse the repository at this point in the history
feat(): added automatic Readme actions
  • Loading branch information
tiagosiebler authored Sep 30, 2024
2 parents 55e6b0b + 11b714a commit 2500395
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 4 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/templates-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Update README.md templates

on:
workflow_dispatch:

permissions:
contents: write # Grant write permissions to the contents

env:
FILE_NAME: README.md

jobs:
update-readme:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org/
cache: 'npm'

- name: Install
run: npm ci --ignore-scripts

- name: Get the current date and time
id: datetime
run: echo "BRANCH_NAME=$(date +'actions_templates_%Y_%m_%d_%H%M%S')" >> $GITHUB_ENV

- name: Create update-template.sh script
run: |
cat << 'EOF' > update-template.sh
#!/bin/bash
TEMPLATE_VALUE=$(curl -s $TEMPLATE_URL)
perl -0777 -i -pe "
my \$tag = quotemeta('<!-- template_${TEMPLATE_TAG} -->');
my \$end_tag = quotemeta('<!-- template_${TEMPLATE_TAG}_end -->');
my \$replacement = '${TEMPLATE_VALUE}';
# Match the tag, then any amount of whitespace (including newlines), then the replacement, then any amount of whitespace, then the end tag.
s/(\$tag)(\s*)(.*?)(\s*)(\$end_tag)/\$1\n\$replacement\n\$5/s;
" "$FILE_NAME"
EOF
chmod +x update-template.sh
cat update-template.sh
- name: Fetch and update RELATED PROJECTS template
run: ./update-template.sh
env:
TEMPLATE_URL: https://raw.githubusercontent.com/wiki/tiagosiebler/awesome-crypto-examples/Related-projects.md
TEMPLATE_TAG: related_projects

- name: Fetch and update CONTRIBUTIONS template
run: ./update-template.sh
env:
TEMPLATE_URL: https://raw.githubusercontent.com/wiki/tiagosiebler/awesome-crypto-examples/Contributions-%26-Thanks.md
TEMPLATE_TAG: contributions

- name: Fetch and update STAR HISTORY template
run: ./update-template.sh
env:
TEMPLATE_URL: https://raw.githubusercontent.com/wiki/tiagosiebler/awesome-crypto-examples/Star-History.md
TEMPLATE_TAG: star_history

- name: Check for changes before running linter
run: git diff

- name: Check for changes | PR URL HERE
id: commitIfChanged
run: |
npx prettier -w README.md
if git diff --quiet; then
echo "No changes to commit"
exit 0
fi
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b ${{ env.BRANCH_NAME }}
git add $FILE_NAME
git commit -m 'chore(): ${{ env.FILE_NAME }} template sections'
git push origin ${{ env.BRANCH_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ Refer to the [examples](./examples) folder for implementation demos.
- Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram.
- Questions about Binance APIs & WebSockets? Ask in the official [Binance API](https://t.me/binance_api_english) group on telegram.

<!-- template_related_projects -->

## Related projects

Check out my related JavaScript/TypeScript/Node.js projects:

- Try my REST API & WebSocket SDKs:
- [Bybit-api Node.js SDK](https://www.npmjs.com/package/bybit-api)
- [Binance Node.js SDK](https://www.npmjs.com/package/binance)
- [Okx-api Node.js SDK](https://www.npmjs.com/package/okx-api)
- [Binance Node.js SDK](https://www.npmjs.com/package/binance)
- [Gateio-api Node.js SDK](https://www.npmjs.com/package/gateio-api)
- [Bitget-api Node.js SDK](https://www.npmjs.com/package/bitget-api)
- [Bitmart-api Node.js SDK](https://www.npmjs.com/package/bitmart-api)
Expand All @@ -76,6 +78,7 @@ Check out my related JavaScript/TypeScript/Node.js projects:
- [Crypto Exchange Account State Cache](https://www.npmjs.com/package/accountstate)
- Check out my examples:
- [awesome-crypto-examples Node.js](https://github.com/tiagosiebler/awesome-crypto-examples)
<!-- template_related_projects_end -->

## Documentation

Expand Down Expand Up @@ -376,7 +379,7 @@ However, note that browser usage will lead to CORS errors due to Binance.
---
## Contributions & Thanks
<!-- template_contributions -->
Have my projects helped you? Share the love, there are many ways you can show your thanks:
Expand All @@ -386,12 +389,23 @@ Have my projects helped you? Share the love, there are many ways you can show yo
- Or buy me all the coffee:
- ETH(ERC20): `0xA3Bda8BecaB4DCdA539Dc16F9C54a592553Be06C` <!-- metamask -->
For more ways to give thanks & support my efforts, visit [Contributions & Thanks](https://github.com/tiagosiebler/awesome-crypto-examples/wiki/Contributions-&-Thanks)!
<!---
old ones:
- BTC: `1C6GWZL1XW3jrjpPTS863XtZiXL1aTK7Jk`
- BTC(SegWit): `bc1ql64wr9z3khp2gy7dqlmqw7cp6h0lcusz0zjtls`
- ETH(ERC20): `0xe0bbbc805e0e83341fadc210d6202f4022e50992`
- USDT(TRC20): `TA18VUywcNEM9ahh3TTWF3sFpt9rkLnnQa
-->
<!-- template_contributions_end -->

### Contributions & Pull Requests

Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.

<!-- template_star_history -->

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/bybit-api,tiagosiebler/binance,tiagosiebler/orderbooks,tiagosiebler/okx-api,tiagosiebler/bitget-api,tiagosiebler/awesome-crypto-examples,tiagosiebler/bitmart-api,tiagosiebler/gateio-api&type=Date)](https://star-history.com/#tiagosiebler/bybit-api&tiagosiebler/binance&tiagosiebler/orderbooks&tiagosiebler/okx-api&tiagosiebler/bitget-api&tiagosiebler/awesome-crypto-examples&tiagosiebler/bitmart-api&tiagosiebler/gateio-api&Date)
[![Star History Chart](https://api.star-history.com/svg?repos=tiagosiebler/bybit-api,tiagosiebler/okx-api,tiagosiebler/binance,tiagosiebler/bitget-api,tiagosiebler/bitmart-api,tiagosiebler/gateio-api,tiagosiebler/kucoin-api,tiagosiebler/orderbooks,tiagosiebler/accountstate,tiagosiebler/awesome-crypto-examples&type=Date)](https://star-history.com/#tiagosiebler/bybit-api&tiagosiebler/okx-api&tiagosiebler/binance&tiagosiebler/bitget-api&tiagosiebler/bitmart-api&tiagosiebler/gateio-api&tiagosiebler/kucoin-api&tiagosiebler/orderbooks&tiagosiebler/accountstate&tiagosiebler/awesome-crypto-examples&Date)

<!-- template_star_history_end -->

0 comments on commit 2500395

Please sign in to comment.