Skip to content

Feat/student discharge #7

Feat/student discharge

Feat/student discharge #7

Workflow file for this run

name: Pull Request CI
on:
pull_request:
branches:
- master
jobs:
validate-workflows:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for workflow changes
id: check_workflow_changes
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
if echo "$CHANGED_FILES" | grep -q ".github/workflows/"; then
echo "Workflow files were modified. This is not allowed."
echo "has_workflow_changes=true" >> $GITHUB_OUTPUT
exit 1
else
echo "No workflow files were modified."
echo "has_workflow_changes=false" >> $GITHUB_OUTPUT
fi
analyze-changes:
runs-on: ubuntu-latest
needs: validate-workflows
outputs:
should_build: ${{ steps.check_changes.outputs.should_build }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check for app changes
id: check_changes
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
APP_PATTERNS="lib/ pubspec.yaml test/ android/ ios/ linux/ macos/ web/ windows/ assets/"
SHOULD_BUILD=false
for pattern in $APP_PATTERNS; do
if echo "$CHANGED_FILES" | grep -q "$pattern"; then
SHOULD_BUILD=true
break
fi
done
echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT
if [ "$SHOULD_BUILD" = "true" ]; then
echo "App files were modified. Build will be triggered."
else
echo "Only documentation or non-app files were modified. Build will be skipped."
fi
build-app:
needs: analyze-changes
if: needs.analyze-changes.outputs.should_build == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.29.3'
channel: 'stable'
cache: true
- name: Install dependencies
run: flutter pub get
- name: Verify formatting
run: dart format --output=none --set-exit-if-changed lib/
- name: Analyze project source
run: flutter analyze
- name: Run tests
run: flutter test --dart-define=TEST_USERNAME=${{ secrets.TEST_USERNAME }} --dart-define=TEST_PASSWORD=${{ secrets.TEST_PASSWORD }}
- name: Build APK
run: flutter build apk --release
- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: release-apk
path: build/app/outputs/flutter-apk/app-release.apk
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
✅ CI build completed successfully!
The APK is available as an artifact in this workflow run.
Download the APK from: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
pr_number: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}