Skip to content

Commit

Permalink
feat(actions): flutter pub get auto action
Browse files Browse the repository at this point in the history
If there are any changes as a result of running `flutter pub get`, post a comment from the GitHub bot asking the PR author to run `flutter pub get` and push the changes.
  • Loading branch information
GroovinChip committed Feb 20, 2023
1 parent 10dda17 commit 7b5ea17
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
39 changes: 33 additions & 6 deletions .github/workflows/flutter_analysis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,54 @@
name: Flutter Analysis
on: [pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch, pull_request_target]

jobs:
package-analysis:
permissions:
id-token: write
contents: read
issues: write
pull-requests: write
runs-on: ubuntu-latest

outputs:
hasLockfileChanges: ${{ steps.installDeps.hasLockfileChanges }}

steps:
- uses: actions/checkout@v3
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: stable

- name: Install dependencies
run: flutter pub get

- uses: actions/checkout@v3
- name: Set up git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Install dependencies
id: installDeps
run: |
flutter pub get
if [[ `git status --porcelain` ]]; then
echo "hasLockfileChanges=yes" >> $GITHUB_OUTPUT
echo "flutter pub get resulted in changes to pubspec.lock"
else
echo "hasLockfileChanges=no" >> $GITHUB_OUTPUT
echo "No changes to pubspec.lock!"
fi
- name: Conditionally request changes
uses: actions/github-script@v6
if: steps.installDeps.outputs.hasLockfileChanges == 'yes'
with:
script: |
github.rest.issues.createComment({
owner: "macosui",
repo: "macos_ui",
issue_number: ${{ github.event.pull_request.number }},
body: "Hello @${{ github.event.pull_request.head.user.login }}! It appears that your `pubspec.lock` file is out of date. Please run `flutter pub get` and push the changes. Thanks!",
});
- name: Format code
run: |
dart format --set-exit-if-changed .
Expand All @@ -38,4 +66,3 @@ jobs:

- name: Test code
run: flutter test

2 changes: 1 addition & 1 deletion .github/workflows/stable_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
script: |
github.rest.repos.createRelease({
owner: "GroovinChip",
owner: "macosui",
repo: "macos_ui",
name: "Version ${{ steps.package-version.outputs.version-number }}",
tag_name: "${{ steps.package-version.outputs.version-number }}",
Expand Down

0 comments on commit 7b5ea17

Please sign in to comment.