Files
gitea-docs/.gitea/workflows/update_swagger.yaml
yp05327 4183476129 Fix CI error in update swagger files (#145)
If there's no changes, the CI will end with exit 1.
<img width="689" alt="image.png" src="attachments/62248c28-6767-4b56-9e06-571e13feb867">

Co-authored-by: Lunny Xiao <lunny@noreply.gitea.com>
Reviewed-on: https://gitea.com/gitea/docs/pulls/145
Reviewed-by: Lunny Xiao <lunny@noreply.gitea.com>
Co-authored-by: yp05327 <576951401@qq.com>
Co-committed-by: yp05327 <576951401@qq.com>
2025-01-09 18:48:57 +00:00

29 lines
1.1 KiB
YAML

name: update swagger files
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
rm v1_json.tmpl
wget https://github.com/go-gitea/gitea/blob/v1.22.4/templates/swagger/v1_json.tmpl
sed -i "$@" 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.22.6"/' static/swagger-22.json
rm v1_json.tmpl
if ! [[ $(git diff --shortstat) ]]; then exit 0; fi
git config --global user.name "Gitea Bot"
git config --global user.email "teabot@gitea.io"
git remote set-url origin https://x-access-token:${{ secrets.DEPLOY_TOKEN }}@gitea.com/gitea/docs.git
git add --all
git commit -m "[skip ci] Updated swagger files"
git push