Generate README #290
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate README | |
concurrency: | |
group: generate-readme-${{ github.event.number }} | |
cancel-in-progress: true | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
schedule: | |
- cron: "31 1,12 * * *" | |
push: | |
branches: | |
- main | |
jobs: | |
generate-readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Setup Deno | |
uses: denolib/setup-deno@v2 | |
with: | |
deno-version: v1.30 | |
- name: Download indexes | |
run: | | |
URLS=( | |
https://raw.githubusercontent.com/nanlabs/frontend-reference/main/examples.json | |
https://raw.githubusercontent.com/nanlabs/devops-reference/main/examples.json | |
https://raw.githubusercontent.com/nanlabs/backend-reference/main/examples.json | |
) | |
# Download files preventing duplicated names (e.g. examples.json) | |
i=0 | |
for url in "${URLS[@]}"; do | |
filename=$(basename "$url") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
filename="$filename-$i.$extension" | |
curl -s "$url" -o "$filename" | |
i=$((i + 1)) | |
done | |
- name: Generate README | |
run: | | |
# Get the list of examples previously downloaded | |
EXAMPLES=$(ls examples-*.json) | |
# Generate the README | |
./tools/readme-generator/main.ts README.md.tmpl examples.json $EXAMPLES | |
# Remove the downloaded files | |
rm examples-*.json | |
- name: Run prettier | |
run: npx prettier --write README.md | |
- name: Run markdownlint | |
uses: articulate/actions-markdownlint@v1 | |
with: | |
fix: true | |
files: README.md | |
- name: Run Awesome Lint | |
run: npx awesome-lint | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v7 | |
with: | |
message: "Update README" |