Merge pull request #923 from rluvaton/fix/update-last-update-badge

fix update last update github action
This commit is contained in:
Yoni Goldberg
2021-03-26 18:32:12 +03:00
committed by GitHub
3 changed files with 33 additions and 38 deletions

View File

@ -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'

View 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: ''

View File

@ -33,16 +33,12 @@ is_last_update_badge_date_is_today() {
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
CALENDAR_EMOJI_ENCODED='%F0%9F%93%85'
# 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
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
echo "No need to update the $INPUT_FILE, the last update badge already pointing to today"
set_update_result "false"
exit 0
fi
sed -i "s/$LAST_UPDATE_BADGE_REGEX/$UPDATED_LAST_UPDATE_BADGE/" "$INPUT_FILE"
set_update_result "true"