update-best-of-list #164
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
# Based on https://github.com/best-of-lists/best-of-update-action/blob/v0.8.5/workflows/update-best-of-list.yml | |
name: update-best-of-list | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Version to use for this update" | |
required: false | |
schedule: | |
- cron: "0 18 * * 4" # Every thursday at 6pm | |
env: | |
BRANCH_PREFIX: "update/" | |
DEFAULT_BRANCH: "main" | |
jobs: | |
update-best-of-list: | |
runs-on: ubuntu-latest | |
environment: env-update-best-of-list | |
steps: | |
- if: ${{ github.event.inputs != null && github.event.inputs.version != null }} | |
name: set-version-from-input | |
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
- if: ${{ ! (env.VERSION != null && env.VERSION != '') }} | |
name: set-version-via-date | |
run: echo "VERSION=$(date '+%Y.%m.%d')" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
- name: check-version-tag | |
shell: bash | |
run: | | |
git fetch --tags --force | |
git show-ref --tags --verify --quiet -- "refs/tags/${{ env.VERSION }}" && echo "VERSION=$(date '+%Y.%m.%d-%H.%M')" >> $GITHUB_ENV || exit 0 | |
- name: create-update-branch | |
uses: peterjgrainger/action-create-branch@v3.0.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
branch: "${{ env.BRANCH_PREFIX }}${{ env.VERSION }}" | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ env.BRANCH_PREFIX }}${{ env.VERSION }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: update-best-of-list | |
# original action, last update, release v0.8.5 on Jan 11, 2022 | |
uses: best-of-lists/best-of-update-action@v0.8.5 | |
# # personal fork, last update, release v0.1.1 on Aug 13, 2024 | |
# # for now, for debugging only | |
# uses: Irratzo/best-of-lists_best-of-update-action@v0.1.1 | |
with: | |
libraries_key: ${{ secrets.LIBRARIES_KEY }} | |
github_key: ${{ secrets.GITHUB_TOKEN }} | |
- name: push-update | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
branch: ${{ env.BRANCH_PREFIX }}${{ env.VERSION }} | |
commit_user_name: best-of update | |
commit_user_email: actions@github.com | |
commit_message: Update best-of list for version ${{ env.VERSION }} | |
tagging_message: ${{ env.VERSION }} | |
skip_dirty_check: true | |
commit_options: "--allow-empty" | |
- name: create-pull-request | |
shell: bash | |
run: | | |
# Stops script execution if a command has an error | |
set -e | |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2 | |
bin/hub pull-request -b ${{ env.DEFAULT_BRANCH }} -h ${{ env.BRANCH_PREFIX }}${{ env.VERSION }} --no-edit -m "Best-of update: ${{ env.VERSION }}" -m "To finish this update: Select <code>Merge pull request</code> below and <code>Confirm merge</code>. Also, make sure to publish the created draft release in the [releases section](../releases) as well." || true | |
rm bin/hub | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: create-release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: "Update: ${{ env.VERSION }}" | |
body_path: "latest-changes.md" | |
draft: true | |
prerelease: false |