diff --git a/.github/actions/bootstrap/action.yaml b/.github/actions/bootstrap/action.yaml new file mode 100644 index 0000000..fbba0b3 --- /dev/null +++ b/.github/actions/bootstrap/action.yaml @@ -0,0 +1,28 @@ +name: Bootstrap +description: Bootstrap the app and Widgetbook, then build Widgetbook + +runs: + using: composite + steps: + - name: Setup flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + + - name: Bootstrap App + shell: bash + run: | + flutter pub get + flutter gen-l10n + + - name: Bootstrap Widgetbook + working-directory: widgetbook + shell: bash + run: | + flutter pub get + dart run build_runner build -d + + - name: Build Widgetbook + working-directory: widgetbook + shell: bash + run: flutter build web diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..ae6a190 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,32 @@ +name: Deploy Demo + +on: + push: + branches: + - main + +jobs: + deploy: + # Only run it if the service account is set, + # to avoid running it on internal forks (e.g. e2e) + if: ${{ secrets.STORAGE_SERVICE_ACCOUNT != '' }} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Bootstrap + uses: ./.github/actions/bootstrap + + - name: Authenticate Service Account + uses: google-github-actions/auth@v1.0.0 + with: + credentials_json: ${{ secrets.STORAGE_SERVICE_ACCOUNT }} + + - name: Deploy to demo.widgetbook.io + uses: google-github-actions/upload-cloud-storage@v1.0.0 + with: + path: widgetbook/build/web + destination: demo.widgetbook.io + parent: false diff --git a/.github/workflows/widgetbook-build-staging.yaml b/.github/workflows/widgetbook-build-staging.yaml deleted file mode 100644 index 7691c49..0000000 --- a/.github/workflows/widgetbook-build-staging.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: Upload Widgetbook Build - Staging - -on: - push: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - - - name: Build App - run: | - flutter pub get - flutter gen-l10n - - - name: Install Widgetbook CLI - run: dart pub global activate widgetbook_cli - - - name: Build Widgetbook - working-directory: widgetbook - run: | - flutter pub get - dart run build_runner build -d - flutter build web -t lib/main.dart - - - name: Upload Widgetbook - working-directory: widgetbook - run: widgetbook_staging publish --api-key ${{ secrets.WIDGETBOOK_CLOUD_API_KEY_STAGING }} diff --git a/.github/workflows/widgetbook-build.yaml b/.github/workflows/widgetbook-build.yaml deleted file mode 100644 index 89815f8..0000000 --- a/.github/workflows/widgetbook-build.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Upload Widgetbook Build - -on: - push: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - - - name: Build App - run: | - flutter pub get - flutter gen-l10n - - - name: Install Widgetbook CLI - run: dart pub global activate widgetbook_cli - - - name: Build Widgetbook - working-directory: widgetbook - run: | - flutter pub get - dart run build_runner build -d - flutter build web -t lib/main.dart - - - name: Upload Widgetbook - working-directory: widgetbook - run: widgetbook publish --api-key ${{ secrets.WIDGETBOOK_CLOUD_API_KEY }} - - - name: Authenticate Service Account - uses: google-github-actions/auth@v1.0.0 - with: - credentials_json: ${{ secrets.STORAGE_SERVICE_ACCOUNT }} - - - name: Deploy to demo.widgetbook.io - uses: google-github-actions/upload-cloud-storage@v1.0.0 - with: - path: widgetbook/build/web - destination: demo.widgetbook.io - parent: false diff --git a/.github/workflows/widgetbook-cloud.yaml b/.github/workflows/widgetbook-cloud.yaml new file mode 100644 index 0000000..b6a1148 --- /dev/null +++ b/.github/workflows/widgetbook-cloud.yaml @@ -0,0 +1,36 @@ +name: Widgetbook Cloud + +on: push + +jobs: + staging: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Bootstrap + uses: ./.github/actions/bootstrap + + - name: Install Widgetbook CLI + run: dart pub global activate widgetbook_cli + + - name: Upload Widgetbook + working-directory: widgetbook + run: widgetbook_staging cloud build push --api-key ${{ secrets.WIDGETBOOK_CLOUD_API_KEY_STAGING }} + + production: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Bootstrap + uses: ./.github/actions/bootstrap + + - name: Install Widgetbook CLI + run: dart pub global activate widgetbook_cli + + - name: Upload Widgetbook + working-directory: widgetbook + run: widgetbook cloud build push --api-key ${{ secrets.WIDGETBOOK_CLOUD_API_KEY }} diff --git a/.github/workflows/widgetbook-review-staging.yaml b/.github/workflows/widgetbook-review-staging.yaml deleted file mode 100644 index 45e45ac..0000000 --- a/.github/workflows/widgetbook-review-staging.yaml +++ /dev/null @@ -1,45 +0,0 @@ -name: Upload Widgetbook Review - Staging - -on: - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - - - name: Build App - run: | - flutter pub get - flutter gen-l10n - - - name: Install Widgetbook CLI - run: dart pub global activate widgetbook_cli - - - name: Build Widgetbook - working-directory: widgetbook - run: | - flutter pub get - dart run build_runner build -d - flutter build web -t lib/main.dart - - - name: Upload Widgetbook - working-directory: widgetbook - run: | - widgetbook_staging publish \ - --api-key ${{ secrets.WIDGETBOOK_CLOUD_API_KEY_STAGING }} \ - --repository $GITHUB_REPOSITORY \ - --actor $GITHUB_ACTOR \ - --base-branch $GITHUB_BASE_REF \ - --branch $GITHUB_HEAD_REF \ - --commit ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/widgetbook-review.yaml b/.github/workflows/widgetbook-review.yaml deleted file mode 100644 index 1495d1d..0000000 --- a/.github/workflows/widgetbook-review.yaml +++ /dev/null @@ -1,45 +0,0 @@ -name: Upload Widgetbook Review - -on: - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - - - name: Build App - run: | - flutter pub get - flutter gen-l10n - - - name: Install Widgetbook CLI - run: dart pub global activate widgetbook_cli - - - name: Build Widgetbook - working-directory: widgetbook - run: | - flutter pub get - dart run build_runner build -d - flutter build web -t lib/main.dart - - - name: Upload Widgetbook - working-directory: widgetbook - run: | - widgetbook publish \ - --api-key ${{ secrets.WIDGETBOOK_CLOUD_API_KEY }} \ - --repository $GITHUB_REPOSITORY \ - --actor $GITHUB_ACTOR \ - --base-branch $GITHUB_BASE_REF \ - --branch $GITHUB_HEAD_REF \ - --commit ${{ github.event.pull_request.head.sha }}