From 9875ed52f3a1fc00733123bd4f9e8161e4429fe2 Mon Sep 17 00:00:00 2001 From: Raz Luvaton Date: Mon, 15 Mar 2021 20:27:50 +0200 Subject: [PATCH 1/2] fix update last update github action to be in the right directory and use the right date --- .github/update-date-in-last-update-badge.yml | 30 ----------------- .../update-date-in-last-update-badge.yml | 32 +++++++++++++++++++ .../update-last-update-badge.sh | 4 +-- 3 files changed, 34 insertions(+), 32 deletions(-) delete mode 100644 .github/update-date-in-last-update-badge.yml create mode 100644 .github/workflows/update-date-in-last-update-badge.yml rename .github/{ => workflows}/update-last-update-badge.sh (97%) diff --git a/.github/update-date-in-last-update-badge.yml b/.github/update-date-in-last-update-badge.yml deleted file mode 100644 index 12206292..00000000 --- a/.github/update-date-in-last-update-badge.yml +++ /dev/null @@ -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' \ No newline at end of file diff --git a/.github/workflows/update-date-in-last-update-badge.yml b/.github/workflows/update-date-in-last-update-badge.yml new file mode 100644 index 00000000..fd354c9a --- /dev/null +++ b/.github/workflows/update-date-in-last-update-badge.yml @@ -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: '' diff --git a/.github/update-last-update-badge.sh b/.github/workflows/update-last-update-badge.sh similarity index 97% rename from .github/update-last-update-badge.sh rename to .github/workflows/update-last-update-badge.sh index 891141dc..89c075b4 100644 --- a/.github/update-last-update-badge.sh +++ b/.github/workflows/update-last-update-badge.sh @@ -42,7 +42,7 @@ set_update_result() { 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=' Date: Fri, 19 Mar 2021 12:37:23 +0200 Subject: [PATCH 2/2] refactor(update-last-update-badge.sh): remove writing script result to env No longer needed as used different action in the workflow yml file --- .github/workflows/update-last-update-badge.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/update-last-update-badge.sh b/.github/workflows/update-last-update-badge.sh index 89c075b4..66fd2510 100644 --- a/.github/workflows/update-last-update-badge.sh +++ b/.github/workflows/update-last-update-badge.sh @@ -33,10 +33,6 @@ 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' @@ -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"