Skip to content

Commit

Permalink
ci: Align PR action with zeta
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 16, 2024
1 parent 609fc83 commit 7e609e3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @benken @thelukewalton @mikecoomber #@ps9310
* @benken @thelukewalton @mikecoomber @ps9310
58 changes: 25 additions & 33 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,49 @@ concurrency:
cancel-in-progress: true

jobs:
set-env:
name: "Set environment"
runs-on: ubuntu-latest
outputs:
env: ${{ steps.get_env.outputs.env }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
- name: Determine Environment
id: get_env
run: |
codeowners=$(cat .github/CODEOWNERS)
if [[ $(echo "${codeowners[@]}" | fgrep -w "@${{github.actor}}") ]]; then
echo PROWNER
echo "env=pr_owner" >> $GITHUB_OUTPUT
else
echo PR
echo "env=pr" >> $GITHUB_OUTPUT
fi
code-quality:
name: Code quality
runs-on: ubuntu-latest
timeout-minutes: 20
needs: set-env
environment: ${{needs.set-env.outputs.env}}
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 0
- uses: subosito/flutter-action@v2
with:
cache: true

- uses: ZebraDevs/flutter-code-quality@v1.0.4
- run: dart run build_runner build --delete-conflicting-outputs
- uses: ZebraDevs/flutter-code-quality@main
with:
token: ${{secrets.GITHUB_TOKEN}}
run-tests: false
run-coverage: false
coverage-pass-score: "80"

check-secret:
runs-on: ubuntu-latest
outputs:
secret-exists: ${{ steps.check.outputs.defined }}
steps:
- name: Check PR can access secrets
id: check
run: |
echo "defined=true" >> $GITHUB_OUTPUT;
if [ "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZETA_DS }}" == '' ]; then
echo "defined=false" >> $GITHUB_OUTPUT;
fi
deploy-preview:
name: Deploy preview version of the example app on firebase
needs: code-quality
name: Deploy preview version of the storybook on firebase
needs: [code-quality, check-secret]
if: needs.check-secret.outputs.secret-exists == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
- uses: subosito/flutter-action@v2
with:
cache: true
- name: Setup flutter
run: flutter pub get
- name: Build example app
Expand All @@ -67,6 +61,4 @@ jobs:
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZDS_FLUTTER }}"
expires: 7d
projectId: zds-c9c24
channelId: "pr-${{ github.event.number }}-${{ github.event.pull_request.head.ref }}"

0 comments on commit 7e609e3

Please sign in to comment.