| name: Groundskeeper |
| description: Reusable workflow to run dart format and dart fix on a single package, and create a PR if there are changes. |
| |
| on: |
| workflow_call: |
| inputs: |
| sdk: |
| description: 'Dart SDK version' |
| required: false |
| type: string |
| default: 'dev' |
| directory: |
| description: 'The directory to tidy' |
| required: false |
| type: string |
| default: '.' |
| update-changelog: |
| description: 'Whether to update the changelog' |
| required: false |
| type: boolean |
| default: false |
| changelog-message: |
| description: 'The changelog message' |
| required: false |
| type: string |
| default: '' |
| run-format: |
| description: 'Run dart format' |
| required: false |
| type: boolean |
| default: true |
| run-fix: |
| description: 'Run dart fix --apply' |
| required: false |
| type: boolean |
| default: true |
| branch: |
| description: 'PR branch name' |
| required: false |
| type: string |
| default: 'auto-tidy' |
| title: |
| description: 'PR title' |
| required: false |
| type: string |
| default: 'Tidy: Automated dart format and fix' |
| body: |
| description: 'PR body' |
| required: false |
| type: string |
| default: 'This is an automated PR to apply `dart format` and `dart fix --apply`.' |
| |
| jobs: |
| tidy: |
| runs-on: ubuntu-latest |
| permissions: |
| contents: write |
| pull-requests: write |
| steps: |
| - name: Generate Dart Bot Token |
| id: generate-token |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 |
| with: |
| client-id: ${{ vars.ECOSYSTEM_BOT_CLIENT_ID }} |
| private-key: ${{ secrets.ECOSYSTEM_BOT_PRIVATE_KEY }} |
| |
| - name: Checkout caller repo |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| with: |
| token: ${{ steps.generate-token.outputs.token }} |
| |
| - name: Checkout ecosystem (for tidy script) |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
| with: |
| repository: dart-lang/ecosystem |
| path: .github/ecosystem-helper |
| |
| - uses: dart-lang/setup-dart@6afc89df92d6eb3834022f73cd65adc8cdfcb92d |
| with: |
| sdk: ${{ inputs.sdk }} |
| |
| - name: Resolve dependencies for firehose |
| working-directory: .github/ecosystem-helper/pkgs/firehose |
| run: dart pub get |
| |
| - name: Run Tidy Script |
| working-directory: ${{ inputs.directory }} |
| run: | |
| dart $GITHUB_WORKSPACE/.github/ecosystem-helper/pkgs/firehose/bin/groundskeeper.dart \ |
| --format=${{ inputs.run-format }} \ |
| --fix=${{ inputs.run-fix }} |
| |
| - name: Check for changes |
| id: check_changes |
| working-directory: ${{ inputs.directory }} |
| run: | |
| if [ -n "$(git status --porcelain .)" ]; then |
| echo "changed=true" >> $GITHUB_OUTPUT |
| else |
| echo "changed=false" >> $GITHUB_OUTPUT |
| fi |
| |
| - name: Update changelog |
| if: ${{ inputs.update-changelog && steps.check_changes.outputs.changed == 'true' }} |
| working-directory: .github/ecosystem-helper/pkgs/repo_manage |
| run: | |
| dart pub get |
| dart run bin/report.dart changelog --changelog "../../../../${{ inputs.directory }}/CHANGELOG.md" "${{ inputs.changelog-message }}" |
| |
| - name: Clean up helper |
| run: rm -rf .github/ecosystem-helper |
| |
| - name: Create Pull Request |
| if: steps.check_changes.outputs.changed == 'true' |
| uses: peter-evans/create-pull-request@762a4a5ab172615cc619580088c2a9443915facf |
| with: |
| token: ${{ steps.generate-token.outputs.token }} |
| committer: dart-ecosystem-bot <dart-ecosystem-bot@google.com> |
| author: dart-ecosystem-bot <dart-ecosystem-bot@google.com> |
| commit-message: ${{ inputs.title }} |
| branch: ${{ inputs.branch }} |
| title: ${{ inputs.title }} |
| body: ${{ inputs.body }} |
| delete-branch: true |