Skip to content

Commit

Permalink
ci: Add a workflow to run flutter pub upgrade
Browse files Browse the repository at this point in the history
Runs nightly and creates a PR if there's changes
  • Loading branch information
iamsergio committed Apr 22, 2024
1 parent e01912c commit 8303e32
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/flutter-pub-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only

# On demand flutter action to trigger flutter pub upgrade

name: (Scheduled) Runs flutter pub upgrade

on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install wget curl file unzip zip xz-utils -y
- name: Install Dart SDK
uses: dart-lang/setup-dart@v1

- name: Setup git author name
uses: fregante/setup-git-user@v2

- name: pub upgrade on flutter_tests_embedder
run: |
cd tests/flutter_tests_embedder/
flutter pub upgrade
- name: pub upgrade on flutter_tests_embedder
run: |
cd tests/flutter_tests_embedder/
flutter pub upgrade --major-versions
- name: pub upgrade on examples
run: |
cd examples/flutter
flutter pub upgrade --major-versions
- name: pub upgrade on src/flutter
run: |
cd src/flutter
flutter pub upgrade --major-versions
- name: pub upgrade on src/flutter/dart
run: |
cd src/flutter/dart
flutter pub upgrade --major-versions
- name: Create PR
run: sh src/flutter/create_pub_upgrade_pr.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions src/flutter/create_pub_upgrade_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only

# Creates a GitHub PR that upgrades dependencies in pubspec.yml
# called by flutter-pub-update.yml

if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "flutter: run pub upgrade"
git checkout -B flutter/pub-"$(git log -1 --pretty=format:"%H")"
git push --set-upstream origin "$(git branch --show-current)"
gh pr create --base main --title "flutter: run pub upgrade" --body "Automatically created via GH action."
fi

0 comments on commit 8303e32

Please sign in to comment.