From 0d23bcc166633b92eafd89054fcd4fd1430ce344 Mon Sep 17 00:00:00 2001 From: Turbolay Date: Thu, 26 Sep 2024 17:22:11 +0200 Subject: [PATCH] Auto-update version number (#1836) --- .github/workflows/build-and-deploy.yml | 2 + .github/workflows/updateVersion.yml | 53 ++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/updateVersion.yml diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 33a623140..9958537ce 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -4,6 +4,8 @@ on: push: branches: - master + repository_dispatch: + types: [ deploy-to-pages ] jobs: deploy: diff --git a/.github/workflows/updateVersion.yml b/.github/workflows/updateVersion.yml new file mode 100644 index 000000000..9be8d6322 --- /dev/null +++ b/.github/workflows/updateVersion.yml @@ -0,0 +1,53 @@ +name: Update WasabiDoc Version + +on: + repository_dispatch: + types: [update-version] + +jobs: + update-config: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Update config.ts + run: | + NEW_VERSION="${{ github.event.client_payload.new_version }}" + echo "Updating to version: $NEW_VERSION" + sed -i "s/currentVersion: '[^']*'/currentVersion: '$NEW_VERSION'/" docs/.vuepress/config.ts + + - name: Commit changes + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git checkout -b update-version-branch + git add docs/.vuepress/config.ts + git commit -m "Update version to ${{ github.event.client_payload.new_version }}" + git push -f --set-upstream origin update-version-branch + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install GitHub CLI + run: sudo apt-get install gh + + - name: Create Pull Request + run: | + gh pr create --base master --head update-version-branch --title "Update version to ${{ github.event.client_payload.new_version }}" --body "Auto-update version to ${{ github.event.client_payload.new_version }}." + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Merge Pull Request with Admin Privileges + run: | + gh pr merge update-version-branch --admin --squash --delete-branch + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Trigger Deployment + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/dispatches \ + -d '{"event_type":"deploy-to-pages"}' \ No newline at end of file