From 5dcf15d47cafef83a58ae294a10466d21614b267 Mon Sep 17 00:00:00 2001 From: dplocki Date: Mon, 24 Jun 2024 20:08:16 +0200 Subject: [PATCH] ci: add generate_readme.yml workflow --- .github/workflows/generate_readme.yml | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/generate_readme.yml diff --git a/.github/workflows/generate_readme.yml b/.github/workflows/generate_readme.yml new file mode 100644 index 0000000..c264540 --- /dev/null +++ b/.github/workflows/generate_readme.yml @@ -0,0 +1,49 @@ +name: Rebuild README.md if necessary + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - name: Getting the sources + uses: actions/checkout@v4 + + - name: Check for prefix in commit messages + id: check_prefix + continue-on-error: true + run: | + git log --format=%B -n 1 $GITHUB_SHA | grep -q "^(feat|refactor):" + echo "prefix_found=1" >> $GITHUB_OUTPUT + + - name: Prepare Node + uses: actions/setup-node@v4 + if: steps.check_prefix.outputs.prefix_found == '1' + with: + node-version: 20 + + - name: Build README.md + if: steps.check_prefix.outputs.prefix_found == '1' + run: | + tmpfile=$(mktemp) + + pushd build + npm ci + node build_readme.js > "$tmpfile" + popd + + mv "$tmpfile" README.md + + - name: Push the generated README.md + uses: EndBug/add-and-commit@v9 + if: steps.check_prefix.outputs.prefix_found == '1' + with: + author_name: 🤖 CompileBot + author_email: CompileBot@happyrobots.com + message: 'chore: update README.md' + add: 'README.md'