Skip to content

Commit 803dacb

Browse files
Merge pull request #93 from YDX-2147483647/ci-refactor
2 parents a2132c8 + 86374a9 commit 803dacb

File tree

1 file changed

+19
-43
lines changed

1 file changed

+19
-43
lines changed

.github/workflows/update-best-of-list.yml

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,72 +12,48 @@ on:
1212

1313
env:
1414
BRANCH_PREFIX: "update/"
15-
DEFAULT_BRANCH: "main"
1615

1716
jobs:
1817
update-best-of-list:
1918
runs-on: ubuntu-latest
2019
steps:
21-
- if: ${{ github.event.inputs != null && github.event.inputs.version != null }}
22-
name: set-version-from-input
20+
- name: Set version from input
21+
if: ${{ github.event.inputs != null && github.event.inputs.version != null }}
2322
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
24-
- if: ${{ ! (env.VERSION != null && env.VERSION != '') }}
25-
name: set-version-via-date
23+
- name: Set version via date
24+
if: ${{ ! (env.VERSION != null && env.VERSION != '') }}
2625
run: echo "VERSION=$(date '+%Y.%m.%d')" >> $GITHUB_ENV
27-
- uses: actions/checkout@v2
28-
- name: check-version-tag
26+
- uses: actions/checkout@v3
27+
- name: Append time to version if necessary
2928
shell: bash
3029
run: |
3130
git fetch --tags --force
3231
git show-ref --tags --verify --quiet -- "refs/tags/${{ env.VERSION }}" && echo "VERSION=$(date '+%Y.%m.%d-%H.%M')" >> $GITHUB_ENV || exit 0
33-
- name: create-update-branch
34-
uses: peterjgrainger/action-create-branch@v2.0.1
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
with:
38-
branch: "${{ env.BRANCH_PREFIX }}${{ env.VERSION }}"
39-
- uses: actions/checkout@v2
40-
with:
41-
fetch-depth: 0
42-
ref: ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}
43-
token: ${{ secrets.GITHUB_TOKEN }}
44-
env:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
- name: install best-of-generator
32+
- name: Install best-of generator
4733
run: pip install "best-of @ git+https://github.com/YDX-2147483647/best-of-generator.git@best-of-bits"
48-
- name: update-best-of-list
34+
- name: Update best-of list
4935
run: >-
5036
best-of generate projects.yaml
5137
--libraries-key=${{ secrets.LIBRARIES_KEY }}
5238
--github-key=${{ secrets.GITHUB_TOKEN }}
5339
--gitee-key=${{ secrets.GITEE_API_KEY }}
54-
- name: push-update
55-
uses: stefanzweifel/git-auto-commit-action@v4
40+
- name: Create pull request
41+
uses: peter-evans/create-pull-request@v5
5642
with:
5743
branch: ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}
58-
commit_user_name: best-of update
59-
commit_user_email: actions@github.com
60-
commit_message: Update best-of list for version ${{ env.VERSION }}
61-
tagging_message: ${{ env.VERSION }}
62-
skip_dirty_check: true
63-
commit_options: "--allow-empty"
64-
- name: create-pull-request
65-
shell: bash
66-
run: |
67-
# Stops script execution if a command has an error
68-
set -e
69-
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2
70-
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
71-
rm bin/hub
72-
env:
73-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74-
- name: create-release
75-
uses: actions/create-release@v1
44+
committer: best-of update <actions@github.com>
45+
commit-message: Update best-of list for version ${{ env.VERSION }}
46+
title: "Best-of update: ${{ env.VERSION }}"
47+
body: |
48+
To finish this update: Select `Merge pull request` below and `Confirm merge`.
49+
Also, make sure to publish the created draft release in the [releases section](../releases) as well.
50+
- name: Publish release
51+
uses: softprops/action-gh-release@v1
7652
env:
7753
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7854
with:
7955
tag_name: ${{ env.VERSION }}
80-
release_name: "Update: ${{ env.VERSION }}"
56+
name: "Update: ${{ env.VERSION }}"
8157
body_path: "latest-changes.md"
8258
draft: true
8359
prerelease: false

0 commit comments

Comments
 (0)