From e84a95f4dae3271a7949cddbd2ba60299b13c357 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 5 Sep 2024 23:57:00 -0700 Subject: [PATCH] Update swagger files on schedule --- .gitea/workflows/update_swagger.yaml | 30 +++++++++++++++++++++++++++ .trans-copy.sh | 31 ---------------------------- 2 files changed, 30 insertions(+), 31 deletions(-) create mode 100644 .gitea/workflows/update_swagger.yaml delete mode 100644 .trans-copy.sh diff --git a/.gitea/workflows/update_swagger.yaml b/.gitea/workflows/update_swagger.yaml new file mode 100644 index 00000000..c541a42d --- /dev/null +++ b/.gitea/workflows/update_swagger.yaml @@ -0,0 +1,30 @@ +name: update swagger +run-name: update swagger + +on: + schedule: + - cron: '0 */12 * * *' # every 12 hours on the hour + workflow_dispatch: + +jobs: + update-swagger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + wget https://github.com/go-gitea/gitea/blob/main/templates/swagger/v1_json.tmpl + sed -i "$@" 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "dev"/' static/swagger-latest.json + + wget https://github.com/go-gitea/gitea/blob/v1.22.2/templates/swagger/v1_json.tmpl + sed -i "$@" 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.22.2"/' static/swagger-1.22.json + + - name: push swagger to repo + uses: appleboy/git-push-action@v0.0.3 + with: + author_email: "teabot@gitea.io" + author_name: GiteaBot + branch: main + commit: true + commit_message: "[skip ci] Updated swagger files" + remote: "git@gitea.com:gitea/docs.git" + ssh_key: ${{ secrets.DEPLOY_KEY }} diff --git a/.trans-copy.sh b/.trans-copy.sh deleted file mode 100644 index 8440408b..00000000 --- a/.trans-copy.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -set -e - -# -# This script is used to copy the en-US content to our available locales as a -# fallback to always show all pages when displaying a specific locale that is -# missing some documents to be translated. -# -# Just execute the script without any argument and you will get the missing -# files copied into the content folder. We are calling this script within the CI -# server simply by `make trans-copy`. -# - -declare -a LOCALES=( - "zh-cn" - "zh-tw" -) - -ROOT=$(realpath $(dirname $0)/..) - -for SOURCE in $(find ${ROOT}/content -type f -iname *.en-us.md); do - for LOCALE in "${LOCALES[@]}"; do - DEST="${SOURCE%.en-us.md}.${LOCALE}.md" - - if [[ ! -f ${DEST} ]]; then - cp ${SOURCE} ${DEST} - sed -i.bak "s/en\-us/${LOCALE}/g" ${DEST} - rm ${DEST}.bak - fi - done -done \ No newline at end of file