mirror of
https://github.com/goldbergyoni/nodebestpractices.git
synced 2025-10-31 01:28:30 +08:00
Merge pull request #923 from rluvaton/fix/update-last-update-badge
fix update last update github action
This commit is contained in:
30
.github/update-date-in-last-update-badge.yml
vendored
30
.github/update-date-in-last-update-badge.yml
vendored
@ -1,30 +0,0 @@
|
|||||||
name: Update date in last update badge
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
run:
|
|
||||||
name: Update the date in last update badge to today
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Update last update badge
|
|
||||||
run: |
|
|
||||||
# Make file runnable
|
|
||||||
chmod +x "${GITHUB_WORKSPACE}/.github/update-last-update-badge.sh"
|
|
||||||
|
|
||||||
# Run script
|
|
||||||
"${GITHUB_WORKSPACE}/.github/update-last-update-badge.sh" "${GITHUB_WORKSPACE}/README.md"
|
|
||||||
|
|
||||||
- name: Commit changes
|
|
||||||
uses: EndBug/add-and-commit@v7
|
|
||||||
if: env.DID_LAST_UPDATE_BADGE_UPDATED
|
|
||||||
with:
|
|
||||||
author_name: github-actions
|
|
||||||
author_email: 41898282+github-actions[bot]@users.noreply.github.com
|
|
||||||
message: 'update the last update badge to today [skip ci]'
|
|
||||||
add: 'README.md'
|
|
||||||
32
.github/workflows/update-date-in-last-update-badge.yml
vendored
Normal file
32
.github/workflows/update-date-in-last-update-badge.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
name: Update date in last update badge
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
name: Update the date in last update badge to today
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Update last update badge
|
||||||
|
run: |
|
||||||
|
# Make file runnable
|
||||||
|
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/update-last-update-badge.sh"
|
||||||
|
# Run script
|
||||||
|
"${GITHUB_WORKSPACE}/.github/workflows/update-last-update-badge.sh" "${GITHUB_WORKSPACE}/README.md"
|
||||||
|
|
||||||
|
- name: Commit & Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
commit-message: update the last update badge to today [skip ci]
|
||||||
|
author: Update Last Update Badge Action <${{ github.actor }}@users.noreply.github.com>
|
||||||
|
branch: update-last-update-badge
|
||||||
|
delete-branch: true
|
||||||
|
title: 'Update last update badge to today [skip ci]'
|
||||||
|
|
||||||
|
# Force empty body as the action have default body
|
||||||
|
body: ''
|
||||||
@ -33,16 +33,12 @@ is_last_update_badge_date_is_today() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
set_update_result() {
|
|
||||||
echo "DID_LAST_UPDATE_BADGE_UPDATED=$1" >> $GITHUB_ENV
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# We use already encoded string emoji because I'm on Windows and the calendar emoji failed to render
|
# We use already encoded string emoji because I'm on Windows and the calendar emoji failed to render
|
||||||
CALENDAR_EMOJI_ENCODED='%F0%9F%93%85'
|
CALENDAR_EMOJI_ENCODED='%F0%9F%93%85'
|
||||||
|
|
||||||
# Date format example: March 03, 2021
|
# Date format example: March 03, 2021
|
||||||
CURRENT_DATE=`date +"%B %m, %Y"`
|
CURRENT_DATE=`date +"%B %d, %Y"`
|
||||||
|
|
||||||
# We explicitly matching the img.shields.io/badge because when we change the provider of the badge the input will be changed too
|
# We explicitly matching the img.shields.io/badge because when we change the provider of the badge the input will be changed too
|
||||||
LAST_UPDATE_BADGE_REGEX='<img id="last-update-badge" src="https:\/\/img\.shields\.io\/badge\/[^>]*>'
|
LAST_UPDATE_BADGE_REGEX='<img id="last-update-badge" src="https:\/\/img\.shields\.io\/badge\/[^>]*>'
|
||||||
@ -59,10 +55,7 @@ fi
|
|||||||
|
|
||||||
if is_last_update_badge_date_is_today "$INPUT_FILE" "$UPDATED_LAST_UPDATE_BADGE"; then
|
if is_last_update_badge_date_is_today "$INPUT_FILE" "$UPDATED_LAST_UPDATE_BADGE"; then
|
||||||
echo "No need to update the $INPUT_FILE, the last update badge already pointing to today"
|
echo "No need to update the $INPUT_FILE, the last update badge already pointing to today"
|
||||||
set_update_result "false"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i "s/$LAST_UPDATE_BADGE_REGEX/$UPDATED_LAST_UPDATE_BADGE/" "$INPUT_FILE"
|
sed -i "s/$LAST_UPDATE_BADGE_REGEX/$UPDATED_LAST_UPDATE_BADGE/" "$INPUT_FILE"
|
||||||
|
|
||||||
set_update_result "true"
|
|
||||||
Reference in New Issue
Block a user