Move & rewrite Theme logic #1
Workflow file for this run
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: "[Flutter] Tests" | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
android: | |
description: "Build Android?" | |
required: true | |
type: boolean | |
default: false | |
ios: | |
description: "Build iOS?" | |
required: true | |
type: boolean | |
default: false | |
web: | |
description: "Build web?" | |
required: true | |
type: boolean | |
default: true | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
filter: | |
name: Branch name check + Flutter tests | |
runs-on: ubuntu-latest | |
outputs: | |
android: ${{ steps.filter.outputs.android }} | |
ios: ${{ steps.filter.outputs.ios }} | |
lib: ${{ steps.filter.outputs.lib }} | |
web: ${{ steps.filter.outputs.web }} | |
test: ${{ steps.filter.outputs.test }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check branch name | |
id: check_branch | |
if: github.event_name == 'pull_request' | |
run: | | |
if [[ ! ${{ github.event.pull_request.head.ref }} =~ ^([0-9]+\.[0-9]+\.[0-9]+|.*patch.*)$ ]]; then | |
echo "Branch name does not match pattern." | |
echo "valid=false" >> $GITHUB_ENV | |
else | |
echo "Branch name is valid." | |
echo "valid=true" >> $GITHUB_ENV | |
fi | |
- name: Check if comment exists | |
id: check_comment | |
if: (env.valid == 'false' || env.valid == 'true') && github.event_name == 'pull_request' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
REPO_OWNER=${{ github.repository_owner }} | |
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2) | |
if [ "${{ env.valid }}" == "false" ]; then | |
COMMENT_BODY="${{ vars.COMMENT_CLOSED }}" | |
else | |
COMMENT_BODY="${{ vars.COMMENT_NICE }}" | |
fi | |
COMMENTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments") | |
if echo "$COMMENTS" | grep -q "$COMMENT_BODY"; then | |
echo "Comment already exists." | |
echo "comment_exists=true" >> $GITHUB_ENV | |
else | |
echo "Comment does not exist." | |
echo "comment_exists=false" >> $GITHUB_ENV | |
fi | |
- name: Close PR and comment | |
if: env.valid == 'false' && env.comment_exists == 'false' && github.event_name == 'pull_request' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
REPO_OWNER=${{ github.repository_owner }} | |
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2) | |
COMMENT_BODY="${{ vars.COMMENT_CLOSED }}" | |
curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
-X POST \ | |
-d "{\"body\":\"$COMMENT_BODY\"}" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" | |
curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
-X PATCH \ | |
-d "{\"state\":\"closed\"}" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER" | |
exit 1 | |
- name: Comment nice | |
if: env.valid == 'true' && env.comment_exists == 'false' && github.event_name == 'pull_request' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
REPO_OWNER=${{ github.repository_owner }} | |
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2) | |
COMMENT_BODY="${{ vars.COMMENT_NICE }}" | |
curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
-X POST \ | |
-d "{\"body\":\"$COMMENT_BODY\"}" \ | |
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" | |
- name: Filter paths | |
id: filter | |
if: env.valid == 'true' && github.event_name == 'pull_request' | |
uses: dorny/paths-filter@v3 | |
with: | |
filters: | | |
android: | |
- 'android/**' | |
ios: | |
- 'ios/**' | |
web: | |
- 'web/**' | |
lib: | |
- 'lib/**' | |
- 'pubspec.yaml' | |
test: | |
- 'test/**' | |
- 'analysis_options.yaml' | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
if: ${{ needs.filter.outputs.android == 'true' || needs.filter.outputs.ios == 'true' || needs.filter.outputs.lib == 'true' || needs.filter.outputs.web == 'true' || needs.filter.outputs.test == 'true' || github.event_name != 'pull_request' }} | |
with: | |
channel: "stable" | |
flutter-version: ${{ vars.FLUTTER_VERSION }} | |
cache: true | |
- name: Install dependencies | |
if: ${{ needs.filter.outputs.android == 'true' || needs.filter.outputs.ios == 'true' || needs.filter.outputs.lib == 'true' || needs.filter.outputs.web == 'true' || needs.filter.outputs.test == 'true' || github.event_name != 'pull_request' }} | |
run: flutter pub get | |
- name: Analyze | |
if: ${{ needs.filter.outputs.android == 'true' || needs.filter.outputs.ios == 'true' || needs.filter.outputs.lib == 'true' || needs.filter.outputs.web == 'true' || needs.filter.outputs.test == 'true' || github.event_name != 'pull_request' }} | |
run: flutter analyze --fatal-infos | |
- name: Test | |
if: ${{ needs.filter.outputs.android == 'true' || needs.filter.outputs.ios == 'true' || needs.filter.outputs.lib == 'true' || needs.filter.outputs.web == 'true' || needs.filter.outputs.test == 'true' || github.event_name != 'pull_request' }} | |
run: flutter test | |
build_android: | |
name: Build Android | |
runs-on: ubuntu-latest | |
needs: filter | |
if: github.event.inputs.android == 'true' | |
# if: ${{ needs.filter.outputs.android == 'true' || needs.filter.outputs.lib == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "zulu" | |
java-version: "17.x" | |
cache: "gradle" | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
flutter-version: ${{ vars.FLUTTER_VERSION }} | |
cache: true | |
- name: Build Android | |
run: flutter build appbundle -PuseDebugSigningConfig=true --release | |
build_web: | |
name: Build Web | |
runs-on: ubuntu-latest | |
needs: filter | |
if: github.event.inputs.web != 'false' | |
# if: ${{ needs.filter.outputs.web == 'true' || needs.filter.outputs.lib == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
flutter-version: ${{ vars.FLUTTER_VERSION }} | |
cache: true | |
- name: Build Web | |
run: flutter build web --release |