Skip to content

ci: fix update api and cfg manual workflow #2602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions .github/workflows/update-api-and-cfg-manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ permissions:
contents: read

jobs:
sync-en-doc:
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 }}
Expand All @@ -39,18 +39,36 @@ jobs:

- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: "emqx-*-schema-dump"
pattern: "emqx*-schema-dump"
repository: ${{ env.REPOSITORY }}
run-id: ${{ env.RUN_ID }}
github-token: ${{ secrets.PAT_RO_WORKFLOWS }}
merge-multiple: true

- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: "emqx-docker"
repository: ${{ env.REPOSITORY }}
run-id: ${{ env.RUN_ID }}
github-token: ${{ secrets.PAT_RO_WORKFLOWS }}

- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
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 }}
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)
Expand All @@ -60,11 +78,22 @@ jobs:
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
EMQX_TAG=$(docker load < emqx-docker-*.tar.gz | sed 's/Loaded image: //g')
EMQX_ENTERPRISE_TAG=$(docker load < emqx-enterprise-docker-*.tar.gz | sed 's/Loaded image: //g')

for edition in ce ee; do
PROFILE=$(echo "${edition}" | sed 's/ce/emqx/g' | sed 's/ee/emqx-enterprise/g')
case "${edition}" in
ce)
PROFILE=emqx
DOCKER_IMAGE=${EMQX_TAG}
;;
ee)
PROFILE=emqx-enterprise
DOCKER_IMAGE=${EMQX_ENTERPRISE_TAG}
;;
esac
for lang in en zh; do
docker run -d --name emqx -p 18083:18083 -e EMQX_dashboard__i18n_lang=${lang} "emqx/${PROFILE}:${EMQX_VERSION}"
docker run -d --name emqx -p 18083:18083 -e EMQX_dashboard__i18n_lang=${lang} "${DOCKER_IMAGE}"
curl -fsS -m 10 --retry 10 --retry-all-errors -o /dev/null http://localhost:18083/api-docs/swagger.json
./rewrite-swagger.sh ${edition} ${lang}
docker logs emqx
Expand Down