chore(ci): create-branch.yml (#5678)

* chore(ci): create branch

* fix: bug

* fix: bug

* fix: secrets

* fix: plugins

* chore: test

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update
This commit is contained in:
YANG QIA 2024-11-18 22:00:16 +08:00 committed by GitHub
parent 8aa65fed5a
commit 4992af56a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 99 additions and 0 deletions

56
.github/workflows/create-branch.yml vendored Normal file
View File

@ -0,0 +1,56 @@
name: Create branch for plugin repos
on:
workflow_dispatch:
inputs:
base:
description: 'Base branch name'
new:
description: 'New branch name'
jobs:
get-plugins:
uses: nocobase/nocobase/.github/workflows/get-plugins.yml@main
secrets: inherit
create-branch:
needs: get-plugins
strategy:
fail-fast: false
matrix:
repo:
- 'nocobase'
- 'pro-plugins'
- ${{ fromJSON(needs.get-plugins.outputs.custom-plugins) }}
- ${{ fromJSON(needs.get-plugins.outputs.rc-plugins) }}
- ${{ fromJSON(needs.get-plugins.outputs.beta-plugins) }}
- ${{ fromJSON(needs.get-plugins.outputs.alpha-plugins) }}
- ${{ fromJSON(needs.get-plugins.outputs.unreleased-plugins) }}
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.NOCOBASE_APP_ID }}
private-key: ${{ secrets.NOCOBASE_APP_PRIVATE_KEY }}
repositories: ${{ matrix.repo }}
skip-token-revoke: true
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.base || 'next' }}
repository: nocobase/${{ matrix.repo }}
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Create branch ${{ inputs.new }} (nocobase/${{ matrix.repo }})
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
git checkout ${{ inputs.base || 'next' }}
git pull origin ${{ inputs.base || 'next' }}
git checkout -b ${{ inputs.new || 'develop' }}
git push --set-upstream origin ${{ inputs.new || 'develop'}}

43
.github/workflows/get-plugins.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Get plugins
on:
workflow_call:
outputs:
custom-plugins:
value: ${{ jobs.get-plugins.outputs.custom-plugins }}
rc-plugins:
value: ${{ jobs.get-plugins.outputs.rc-plugins }}
beta-plugins:
value: ${{ jobs.get-plugins.outputs.beta-plugins }}
alpha-plugins:
value: ${{ jobs.get-plugins.outputs.alpha-plugins }}
unreleased-plugins:
value: ${{ jobs.get-plugins.outputs.unreleased-plugins }}
jobs:
get-plugins:
runs-on: ubuntu-latest
outputs:
custom-plugins: ${{ steps.get-plugins.outputs.custom-plugins }}
rc-plugins: ${{ steps.get-plugins.outputs.rc-plugins }}
beta-plugins: ${{ steps.get-plugins.outputs.beta-plugins }}
alpha-plugins: ${{ steps.get-plugins.outputs.alpha-plugins }}
unreleased-plugins: ${{ steps.get-plugins.outputs.unreleased-plugins }}
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.NOCOBASE_APP_ID }}
private-key: ${{ secrets.NOCOBASE_APP_PRIVATE_KEY }}
owner: nocobase
skip-token-revoke: true
- id: get-plugins
shell: bash
run: |
echo "custom-plugins=$(gh search repos "props.plugin-type:custom" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT"
echo "rc-plugins=$(gh search repos "props.plugin-type:rc" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT"
echo "beta-plugins=$(gh search repos "props.plugin-type:beta" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT"
echo "alpha-plugins=$(gh search repos "props.plugin-type:alpha" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT"
echo "unreleased-plugins=$(gh search repos "props.plugin-type:unreleased" --owner=nocobase --json name | jq -r 'map(.name) | tostring')" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}