-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jeromy Cannon <[email protected]>
- Loading branch information
1 parent
97b3065
commit f30186d
Showing
1 changed file
with
11 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,25 +38,28 @@ jobs: | |
- name: Readme Update Check | ||
id: readme-update-check | ||
run: | | ||
# determine if any javascript files change since last "auto update README.md" | ||
# determine if any javascript files changed | ||
git --no-pager diff --name-only ${{ github.event.pull_request.head.ref }} $(git merge-base ${{ github.event.pull_request.head.ref }} ${{ github.event.pull_request.base.ref }}) | ||
CHANGED_FILES=$(git --no-pager diff --name-only ${{ github.event.pull_request.head.ref }} $(git merge-base ${{ github.event.pull_request.head.ref }} ${{ github.event.pull_request.base.ref }}) | grep -E -i ".*\.(mjs|cjs|js|package*\.json)") | ||
[ "${#CHANGED_FILES}" -gt 0 ] && FILES_CHANGED=true || FILES_CHANGED=false | ||
echo "FILES_CHANGED=$FILES_CHANGED" | ||
# determine if commits since last "auto update README.md" commit | ||
git --no-pager log --reverse --pretty="%H|%an|%s" ${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }} | awk '/github-actions\[bot\]\|auto update README\.md/ {s=""; next} {s = s $0 RS} END {printf "%s", s}' | ||
COMMITS_SINCE_UPDATE=$(git --no-pager log --reverse --pretty="%H|%an|%s" ${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }} | awk '/github-actions\[bot\]\|auto update README\.md/ {s=""; next} {s = s $0 RS} END {printf "%s", s}') | ||
[ "${#COMMITS_SINCE_UPDATE}" -gt 0 ] && UPDATE_NEEDED=true || UPDATED_NEEDED=false | ||
echo "UPDATE_NEEDED=$UPDATE_NEEDED" | ||
[ "${$FILES_CHANGED}" == "true" && "${UPDATE_NEEDED}" == "true"] && RUN_UPDATE=true || RUN_UPDATE=false | ||
echo "run-update=$RUN_UPDATE" >> "${GITHUB_OUTPUT}" | ||
- name: Setup Node | ||
if: ${{ steps.readme-update-check.outputs.FILES_CHANGED == 'true' && steps.readme-update-check.outputs.UPDATE_NEEDED == 'true' }} | ||
if: ${{ steps.readme-update-check.outputs.run-update }} | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
with: | ||
node-version: 20 | ||
cache: npm | ||
|
||
- name: Setup Kind | ||
if: ${{ steps.readme-update-check.outputs.FILES_CHANGED == 'true' && steps.readme-update-check.outputs.UPDATE_NEEDED == 'true' }} | ||
if: ${{ steps.readme-update-check.outputs.run-update }} | ||
uses: helm/kind-action@99576bfa6ddf9a8e612d83b513da5a75875caced # v1.9.0 | ||
with: | ||
install_only: true | ||
|
@@ -67,7 +70,7 @@ jobs: | |
wait: 120s | ||
|
||
- name: Install NVM & Dependencies | ||
if: ${{ steps.readme-update-check.outputs.FILES_CHANGED == 'true' && steps.readme-update-check.outputs.UPDATE_NEEDED == 'true' }} | ||
if: ${{ steps.readme-update-check.outputs.run-update }} | ||
id: npm-deps | ||
run: | | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | ||
|
@@ -79,14 +82,14 @@ jobs: | |
npm ci | ||
- name: Install gettext-base | ||
if: ${{ steps.readme-update-check.outputs.FILES_CHANGED == 'true' && steps.readme-update-check.outputs.UPDATE_NEEDED == 'true' }} | ||
if: ${{ steps.readme-update-check.outputs.run-update }} | ||
id: gettext-base | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install gettext-base | ||
- name: Update README.md | ||
if: ${{ steps.readme-update-check.outputs.FILES_CHANGED == 'true' && steps.readme-update-check.outputs.UPDATE_NEEDED == 'true' }} | ||
if: ${{ steps.readme-update-check.outputs.run-update }} | ||
run: | | ||
npm install -g @hashgraph/solo | ||
which solo | ||
|
@@ -137,7 +140,7 @@ jobs: | |
egrep -v '↓|❯|•' README.md > README.md.tmp && mv README.md.tmp README.md | ||
- name: Check README.md Changes | ||
if: ${{ steps.readme-update-check.outputs.FILES_CHANGED == 'true' && steps.readme-update-check.outputs.UPDATE_NEEDED == 'true' }} | ||
if: ${{ steps.readme-update-check.outputs.run-update }} | ||
id: check-readme-changes | ||
run: | | ||
CHANGES=$(git diff --stat) | ||
|
@@ -163,7 +166,7 @@ jobs: | |
# Signed Commits by actions https://github.com/actions/runner/issues/667 | ||
- name: Commit README.md Changes | ||
if: ${{ steps.readme-update-check.outputs.FILES_CHANGED == 'true' && steps.readme-update-check.outputs.UPDATE_NEEDED == 'true' && steps.check-readme-changes.outputs.TOTAL_LINES_CHANGED > 20 }} | ||
if: ${{ steps.readme-update-check.outputs.run-update && steps.check-readme-changes.outputs.TOTAL_LINES_CHANGED > 20 }} | ||
uses: planetscale/[email protected] | ||
with: | ||
commit_message: "auto update README.md" | ||
|