Skip to content

Instantly share code, notes, and snippets.

@wendreof
Created October 16, 2021 05:41
Show Gist options
  • Save wendreof/8287668d549761f360359ba7de774dd6 to your computer and use it in GitHub Desktop.
Save wendreof/8287668d549761f360359ba7de774dd6 to your computer and use it in GitHub Desktop.
publish_ghPages
name: deploy
on: #trigger on push & PR to this branch only
push:
branches:
- master
pull_request:
branches:
- master
env:
JAVA_VERSION: "12.x" #change this version if you want
FLUTTER_VERSION: "2.2.3" #set here your version
FLUTTER_CHANNEL: "stable" #set here your channel
jobs:
flutter_test:
name: Analyze
runs-on: ubuntu-latest #change it to another OS if you want
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: ${{env.JAVA_VERSION}}
- uses: subosito/flutter-action@v1
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
#1 - get depencies
#2 - check if there are some warnings
#3 - format all files at lib folder
- run: |
flutter clean
flutter pub get
flutter analyze
flutter format lib/
build_web:
name: Build for WEB
needs: [flutter_test] #only trigger this, if the flutter_test job runs ok...
runs-on: ubuntu-latest #change it to another OS if you want
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
- run: |
flutter pub get
flutter build web
publish_ghPages:
name: Publish GH Pages
needs: [build_web] #only trigger this, if the build_web job runs ok...
env:
my_secret: ${{secrets.commit_secret}}
runs-on: ubuntu-latest #change it to another OS if you want
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
channel: ${{env.FLUTTER_CHANNEL}}
- run: |
flutter pub get
flutter build web --release
cd build/web
git init
git config --global user.email [email protected] #change to your e-mail
git config --global user.name changeme #change to your user-name
git status
git remote add origin https://${{secrets.commit_secret}}@github.com/your-user/your-repository.git #change to your path
git checkout -b gh-pages
git add --all
git commit -m "update"
git push origin gh-pages -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment