Add Flutter setup composite action for streamlined environment configuration

This commit is contained in:
Dr.Blank 2025-04-04 23:06:58 +05:30
parent d55ddc5b78
commit 49a24b675e
No known key found for this signature in database
GPG key ID: BA5F87FF0560C57B
2 changed files with 64 additions and 7 deletions

View file

@ -0,0 +1,57 @@
# .github/actions/flutter-setup/action.yml
name: "Flutter Setup Composite Action"
description: "Checks out code, sets up Java/Flutter, caches, and runs pub get"
# Define inputs for customization (optional, but good practice)
inputs:
flutter-channel:
description: "Flutter channel to use (stable, beta, dev, master)"
required: false
default: "stable"
java-version:
description: "Java version to set up"
required: false
default: "17"
runs:
using: "composite" # Specify this is a composite action
steps:
# Note: Checkout needs to happen *within the job using the composite action* usually.
# However, for self-contained setup, we can include it here.
# If you need checkout options controlled by the main workflow, move checkout
# to be the first step in the main workflow's job *before* calling this action.
- name: Checkout repository (within composite)
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ inputs.java-version }}
- name: Set up Flutter SDK
uses: subosito/flutter-action@v2
with:
channel: ${{ inputs.flutter-channel }}
flutter-version-file: pubspec.yaml
cache: true # Cache Flutter SDK itself
- name: Cache Flutter dependencies
id: cache-pub
uses: actions/cache@v4
with:
path: ${{ env.FLUTTER_HOME }}/.pub-cache
key: ${{ runner.os }}-flutter-pub-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-flutter-pub-
# Use shell: bash for potential cross-platform compatibility in complex commands
shell: bash
- name: Get Flutter dependencies
run: flutter pub get
# Use shell: bash for potential cross-platform compatibility in complex commands
shell: bash
# Add other common setup steps if needed

View file

@ -14,14 +14,14 @@ on:
jobs:
test:
name: Test
uses: ./.github/workflows/flutter-setup.yaml
secrets: inherit
with:
flutter-channel: stable
java-version: 17
runs-on: ubuntu-latest
steps:
- name: Setup Flutter Environment
uses: ./.github/actions/flutter-setup # Path to the composite action directory
# Pass inputs if needed (optional, using defaults here)
# with:
# flutter-channel: 'stable'
# java-version: '17'
# Debug: Echo current directory contents
- name: List root directory contents
run: |