Update "telegram-bot-api" submodule #725
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
## --------------- Workflow to check updates of tdlib/telegram-bot-api submodule --------------- ## | |
name: Update submodule | |
run-name: Update "telegram-bot-api" submodule | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "30 6 * * *" # Runs at 6:30 AM UTC (12:00 PM IST) Everyday | |
env: | |
GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT }} | |
jobs: | |
update_checks: | |
name: Check Updates | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout current repository | |
uses: actions/checkout@main | |
with: | |
token: ${{ secrets.WORKFLOW_PAT }} | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Checkout submodule updates | |
id: update_status | |
run: | | |
# Get current version | |
current_version=$(cat telegram-bot-api/CMakeLists.txt | grep TelegramBotApi | cut -d " " -f3) | |
# Checkout updates | |
returnedValue=$(git submodule update --remote) | |
# Get new version | |
updated_version=$(cat telegram-bot-api/CMakeLists.txt | grep TelegramBotApi | cut -d " " -f3) | |
# Checks if submodule was updated | |
updated=$([ -n "$returnedValue" ] && echo "true" || echo "false") | |
# Set outputs & summary | |
echo "current_version=$current_version" >> $GITHUB_OUTPUT | |
echo "updated_version=$updated_version" >> $GITHUB_OUTPUT | |
echo "updated=$updated" >> $GITHUB_OUTPUT | |
echo "#### 👉 Submodule Update found: $updated" >> $GITHUB_STEP_SUMMARY | |
- name: Commit submodule updates to main-branch (if updated) | |
if: steps.update_status.outputs.updated == 'true' | |
run: | | |
# Versions | |
current_version=${{ steps.update_status.outputs.current_version }} | |
updated_version=${{ steps.update_status.outputs.updated_version }} | |
# Commit changes | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git add . | |
git commit -am "_deploy_: Updated telegram-bot-api submodule from v${current_version} to v${updated_version}" | |
git push origin main | |
echo "#### ✔️ Submodule Updates commited from v${current_version} to v${updated_version} to main branch" >> $GITHUB_STEP_SUMMARY |