Update API and config manual #106
This file contains hidden or 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
name: Update API and config manual | |
concurrency: | |
group: update-api-cfg-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
repository_dispatch: | |
types: | |
- release | |
workflow_dispatch: | |
inputs: | |
version: | |
type: string | |
required: true | |
description: 'EMQX version without v/e prefix' | |
run_id: | |
type: string | |
required: true | |
description: 'The run id of the workflow that generates the schema dump' | |
permissions: | |
contents: read | |
jobs: | |
update-api-cfg-manual: | |
runs-on: ubuntu-latest | |
env: | |
EMQX_VERSION: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.version || github.event.inputs.version }} | |
RUN_ID: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.run-id || github.event.inputs.run_id }} | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Generate GitHub App token | |
id: app-token | |
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 | |
with: | |
app-id: ${{ vars.AUTH_APP_ID }} | |
private-key: ${{ secrets.AUTH_APP_PRIVATE_KEY }} | |
owner: ${{ github.repository_owner }} | |
repositories: | | |
emqx | |
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
with: | |
pattern: "emqx*-schema-dump" | |
repository: "emqx/emqx" | |
run-id: ${{ env.RUN_ID }} | |
github-token: ${{ steps.app-token.outputs.token }} | |
merge-multiple: true | |
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
if: github.event.inputs.docker_pull == false | |
with: | |
name: "emqx-docker" | |
repository: ${{ env.REPOSITORY }} | |
run-id: ${{ env.RUN_ID }} | |
github-token: ${{ secrets.PAT_RO_WORKFLOWS }} | |
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
if: github.event.inputs.docker_pull == false | |
with: | |
name: "emqx-enterprise-docker" | |
repository: ${{ env.REPOSITORY }} | |
run-id: ${{ env.RUN_ID }} | |
github-token: ${{ secrets.PAT_RO_WORKFLOWS }} | |
- name: Create PR to update api docs and config manual | |
env: | |
GH_TOKEN: ${{ github.token }} | |
DOCKER_PULL: ${{ github.event.inputs.docker_pull }} | |
run: | | |
set -euxo pipefail | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
BASE_BRANCH="$(echo release-$(echo $EMQX_VERSION | cut -d '.' -f 1-2))" | |
NEW_BRANCH="update-api-cfg-${EMQX_VERSION}" | |
git fetch origin ${BASE_BRANCH} | |
git checkout -b ${NEW_BRANCH} --track origin/${BASE_BRANCH} | |
VERSION=$(echo "${EMQX_VERSION}" | cut -d '-' -f 1) | |
MINOR_VERSION=$(echo "${EMQX_VERSION}" | cut -d '.' -f 1-2) | |
sed -i "s/EE_VERSION=.*/EE_VERSION=${VERSION}/" ./current-version.env | |
sed -i "s/EE_MINOR_VERSION=.*/EE_MINOR_VERSION=${MINOR_VERSION}/" ./current-version.env | |
git add current-version.env | |
cp "_build/docgen/emqx-enterprise/schema-v2-en.json" "hocon/hocon-ee-v${VERSION}-en.json" | |
cp "_build/docgen/emqx-enterprise/schema-v2-zh.json" "hocon/hocon-ee-v${VERSION}-zh.json" | |
git add "hocon/hocon-ee-v${VERSION}-en.json" | |
git add "hocon/hocon-ee-v${VERSION}-zh.json" | |
DOCKER_IMAGE="emqx/emqx-enterprise:${EMQX_VERSION}" | |
./update-api-docs.sh "${VERSION}" "${DOCKER_IMAGE}" | |
git add "redocly/ee-en.json" | |
git add "redocly/ee-zh.json" | |
git commit -m "chore(${VERSION}): update api docs and configuration manual" | |
git push origin ${NEW_BRANCH}:${NEW_BRANCH} | |
for pr in $(gh pr list --state open --base ${BASE_BRANCH} --label update-api-cfg --search "update api docs and configuration manual for ${VERSION} in:title" --repo ${{ github.repository }} --json number --jq '.[] | .number'); do | |
gh pr close $pr --repo ${{ github.repository }} --delete-branch || true | |
done | |
gh pr create --title "update api docs and configuration manual for ${VERSION}" --body '' --base ${BASE_BRANCH} --head ${NEW_BRANCH} --label update-api-cfg --repo ${{ github.repository }} | |
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: "swagger" | |
path: | | |
redocly/*.json |