Skip to content

Commit

Permalink
Specify pull request in DCM workflow (#5727)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Apr 27, 2023
1 parent 0db1f57 commit 1c5df0f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/dcm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ jobs:
uses: ./.github/workflows/flutter-prep.yaml
with:
os-name: ubuntu
needs-checkout-merge: true

dcm:
name: Dart Code Metrics
needs: flutter-prep
runs-on: ubuntu-latest
steps:
- name: Clone Flutter DevTools
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
ref: "refs/pull/${{ github.event.number }}/merge"
- name: Load Cached Flutter SDK
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/flutter-prep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
os-name:
description: 'The OS to run against, either "macos" or "ubuntu". If neither is provided, will run against both.'
type: string
needs-checkout-merge:
description: 'Whether the PR should be merged during the checkout step. Necessary for pull_request_target workflows.'
type: boolean
outputs:
latest_flutter_candidate:
description: 'The latest Flutter candidate version.'
Expand All @@ -25,7 +28,21 @@ jobs:
os: ${{ (inputs.os-name == 'macos' && fromJSON('[ "macos-latest"]')) || (inputs.os-name == 'ubuntu' && fromJSON('[ "ubuntu-latest"]')) || fromJSON('["ubuntu-latest", "macos-latest"]') }}
runs-on: ${{ matrix.os }}
steps:
- name: git clone devtools
# TODO(https://github.com/flutter/devtools/issues/5729) Consider caching DevTools so that we
# don't check it out again is subsequent workflows.

# Merge in the PR branch during checkout. This is necessary for pull_request_target workflows.
# See: https://github.com/actions/checkout/issues/518
- name: Checkout PR branch for DevTools
if: ${{ inputs.needs-checkout-merge == true }}
id: checkout-pr-branch
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
ref: "refs/pull/${{ github.event.number }}/merge"

# Otherwise use the default checkout action.
- name: Checkout DevTools (default)
if: steps.checkout-pr-branch.outcome == 'skipped'
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

- name: Get Latest Flutter Candidate
Expand Down

0 comments on commit 1c5df0f

Please sign in to comment.