Auto Update YApi #80404
This file contains 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: Auto Update YApi | |
on: | |
schedule: | |
- cron: '*/30 * * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Update | |
run: | | |
PROJECT_LATEST_TAG=$(wget -q -O- "https://api.github.com/repos/${GITHUB_REPOSITORY}/tags" | grep '"name":' | sed -E 's#.*"(.+)".*#\1#' | head -n1) | |
YAPI_LATEST_TAG=$(wget -q -O- https://api.github.com/repos/YMFE/yapi/tags | grep '"name":' | sed -E 's#.*"v(.+)".*#\1#' | head -n1) | |
echo "YApi: $YAPI_LATEST_TAG" | |
echo "docker-YApi: $PROJECT_LATEST_TAG" | |
if [ $PROJECT_LATEST_TAG != $YAPI_LATEST_TAG ]; then | |
git config user.name "Bot" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
sed -i "s#YAPI_VERSION=.*#YAPI_VERSION=$YAPI_LATEST_TAG#" Dockerfile | |
git add Dockerfile | |
git commit -m "feat: 升级 YApi 版本 [$YAPI_LATEST_TAG]" | |
git tag -a "$YAPI_LATEST_TAG" -m "YApi v$YAPI_LATEST_TAG" | |
git push -u origin master --follow-tags | |
fi |