🚀 Update Telegram Bot API version (mahlenko) #422
This file contains hidden or 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: Get new API version | |
| run-name: 🚀 Update Telegram Bot API version (${{ github.actor }}) | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| schedule: | |
| - cron: 0 0 * * * | |
| env: | |
| repo: 'appto-dev/telegram-bot-cast' | |
| repo-directory: 'telegram-bot-cast' | |
| laravel-repo: 'appto-dev/telegram-bot-cast-laravel' | |
| laravel-directory: 'telegram-bot-cast-laravel' | |
| jobs: | |
| download-new-version: | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| api_version: ${{ steps.download.outputs.api_version }} | |
| steps: | |
| - name: Setup PHP with PECL extension | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install deps | |
| run: | | |
| git pull | |
| rm -rf ${{ env.repo-directory }} | |
| rm -rf ${{ env.laravel-directory }} | |
| composer install --no-dev | |
| - name: Download version Telegram API | |
| id: download | |
| run: | | |
| echo "api_version=$(php console telegram:parse)" >> $GITHUB_OUTPUT | |
| - name: Has new version | |
| id: requires_update | |
| run: | | |
| if git ls-files --other --exclude-standard --directory | grep -i "**"; then | |
| echo "hasUpdate=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "hasUpdate=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Update repository | |
| if: steps.requires_update.outputs.hasUpdate == 'true' | |
| run: | | |
| git add . | |
| git config --global user.email "${{ secrets.REPOSITORY_EMAIL }}" | |
| git config --global user.name "${{ github.actor }}" | |
| git commit -m "[BOT] Version ${{ steps.download.outputs.api_version }} of the Telegram Bot API has been added" | |
| git push | |
| update-repo: | |
| runs-on: ubuntu-22.04 | |
| needs: download-new-version | |
| steps: | |
| - name: Setup PHP with PECL extension | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install deps | |
| run: | | |
| git pull | |
| composer install --no-dev | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: '${{ secrets.GH_ACTION_TELEGRAM_REPOSITORIES }}' | |
| repository: ${{env.repo}} | |
| path: ${{ env.repo-directory }} | |
| - name: Generate files | |
| run: | | |
| rm -rf build | |
| php console telegram:generate | |
| - name: Copy files to repository | |
| run: | | |
| rm -rf ${{ env.repo-directory }}/src | |
| mv build/Appto/TelegramBot ${{ env.repo-directory }}/src | |
| - name: Check update | |
| id: check_update | |
| run: | | |
| cd ${{ env.repo-directory }} | |
| if git ls-files --other --exclude-standard --directory | grep -i "**"; then | |
| echo "hasUpdate=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "hasUpdate=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Push commit | |
| if: steps.check_update.outputs.hasUpdate == 'true' | |
| run: | | |
| cd ${{ env.repo-directory }} | |
| git add . | |
| git config --global user.email "${{ secrets.REPOSITORY_EMAIL }}" | |
| git config --global user.name "${{ github.actor }}" | |
| git commit -m "[BOT] Version ${{ needs.download-new-version.outputs.api_version }} of the Telegram Bot API has been added" | |
| git push origin main | |
| - name: Create Release | |
| if: steps.check_update.outputs.hasUpdate == 'true' | |
| run: | | |
| git tag ${{ needs.download-new-version.outputs.api_version }} -m "Beta ${{ needs.download-new-version.outputs.api_version }}" | |
| git push origin ${{ needs.download-new-version.outputs.api_version }} --tags | |
| update-laravel-version-repo: | |
| runs-on: ubuntu-22.04 | |
| needs: download-new-version | |
| steps: | |
| - name: Setup PHP with PECL extension | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install deps | |
| run: | | |
| git pull | |
| composer install --no-dev | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: '${{ secrets.GH_ACTION_TELEGRAM_REPOSITORIES }}' | |
| repository: ${{env.laravel-repo}} | |
| path: ${{ env.laravel-directory }} | |
| - name: Generate files | |
| run: | | |
| rm -rf build | |
| php console telegram:generate --extends=\\Spatie\\LaravelData\\Data | |
| - name: Copy files to repository | |
| run: | | |
| rm -rf ${{ env.laravel-directory }}/src | |
| mv build/Appto/TelegramBot ${{ env.laravel-directory }}/src | |
| - name: Check update | |
| id: check_update | |
| run: | | |
| cd ${{ env.laravel-directory }} | |
| if git ls-files --other --exclude-standard --directory | grep -i "**"; then | |
| echo "hasUpdate=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "hasUpdate=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Push commit | |
| if: steps.check_update.outputs.hasUpdate == 'true' | |
| run: | | |
| cd ${{ env.laravel-directory }} | |
| git add . | |
| git config --global user.email "${{ secrets.REPOSITORY_EMAIL }}" | |
| git config --global user.name "${{ github.actor }}" | |
| git commit -m "[BOT] Version ${{ needs.download-new-version.outputs.api_version }} of the Telegram Bot API has been added" | |
| git push origin main | |
| - name: Create Release | |
| if: steps.check_update.outputs.hasUpdate == 'true' | |
| run: | | |
| git tag ${{ needs.download-new-version.outputs.api_version }} -m "Beta ${{ needs.download-new-version.outputs.api_version }}" | |
| git push origin ${{ needs.download-new-version.outputs.api_version }} --tags |