Skip to content

update-best-of-list #88

update-best-of-list

update-best-of-list #88

# 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
generator:
description: "Git ref of best-of generator, such as a branch name"
# pip documentation on VSC support: https://pip.pypa.io/en/stable/topics/vcs-support/#git
required: true
default: "best-of-bits"
type: string
schedule:
- cron: "0 1 26 * *"
env:
BRANCH_PREFIX: "update/"
jobs:
update-best-of-list:
runs-on: ubuntu-latest
steps:
- name: Set version from input
if: ${{ github.event.inputs != null && github.event.inputs.version != null }}
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Set version via date
if: ${{ ! (env.VERSION != null && env.VERSION != '') }}
run: echo "VERSION=$(date '+%Y.%m.%d')" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Append time to version if necessary
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: Install best-of generator
run: pip install "best-of @ git+https://github.com/YDX-2147483647/best-of-generator.git@${{ inputs.generator || 'best-of-bits' }}"
- name: Update best-of list
run: >-
best-of generate projects.yaml
--libraries-key=${{ secrets.LIBRARIES_KEY }}
--github-key=${{ secrets.GITHUB_TOKEN }}
--gitee-key=${{ secrets.GITEE_API_KEY }}
- name: Report latest changes
run: |
echo "# Best-of update: ${{ env.VERSION }}" >> "$GITHUB_STEP_SUMMARY"
cat latest-changes.md >> "$GITHUB_STEP_SUMMARY"
- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
branch: ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}
committer: best-of update <[email protected]>
commit-message: Update best-of list for version ${{ env.VERSION }}
title: "Best-of update: ${{ env.VERSION }}"
body: |
To finish this update: Select `Merge pull request` below and `Confirm merge`.
Also, make sure to publish the created draft release in the [releases section](../releases) as well.
- name: Switch to updated branch
# “Create pull request” committed to a new branch without switching to it,
# but “Publish release” needs the updated file.
run: git switch "${{ env.BRANCH_PREFIX }}${{ env.VERSION }}"
- name: Publish release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
name: "Update: ${{ env.VERSION }}"
body_path: "latest-changes.md"
draft: true
prerelease: false