Check for updates #63
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: Check for updates | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
env: | |
GIT_USER_EMAIL: "[email protected]" | |
GIT_USER_NAME: "Andrii Antonov" | |
jobs: | |
check-for-updates: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.USER_PAT }} | |
- name: Setup git credentials | |
run: | | |
git config --global user.email "${{ env.GIT_USER_EMAIL }}" | |
git config --global user.name "${{ env.GIT_USER_NAME }}" | |
- name: Throws if not on main branch | |
run: | | |
gitCurrentBranch=$(git rev-parse --abbrev-ref HEAD) | |
if [[ "$gitCurrentBranch" != "main" ]]; then | |
echo "This action should ONLY be run on main branch" | |
exit 1 | |
fi | |
- name: Install flutter from fvm | |
uses: kuhnroyal/flutter-fvm-config-action/setup@v3 | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Run update files command | |
run: dart ./bin/update_files.dart | |
- name: Run tests | |
run: flutter test | |
- name: Run analysis | |
run: flutter analyze | |
- name: Run format check | |
run: flutter format --set-exit-if-changed --dry-run . | |
- name: Check and Push Latest Tag | |
run: | | |
# Get the latest local tag | |
latest_local_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
if [ -z "$latest_local_tag" ]; then | |
echo "No local tags found. This should not happen. Exiting with error." | |
exit 1 | |
fi | |
echo "Latest local tag: $latest_local_tag" | |
# Check if the latest local tag exists in the remote | |
if git ls-remote --tags origin | grep -q "refs/tags/$latest_local_tag"; then | |
echo "Latest local tag $latest_local_tag already exists in the remote." | |
echo "Nothing to do. Exiting." | |
exit 0 | |
fi | |
echo "Latest local tag $latest_local_tag does not exist in the remote." | |
echo "Pushing changes..." | |
git push origin main | |
# Push the latest local tag | |
echo "Pushing tag $latest_local_tag..." | |
git push origin "$latest_local_tag" |