Update all lint rules #50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update all lint rules | |
on: | |
schedule: | |
- cron: '0 0 * * 3' | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
branch: "update-all-lint-rules-${{ github.run_number }}" | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
outputs: | |
has_diff: ${{ steps.check_diff.outputs.has_diff }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dart-lang/setup-dart@v1 | |
- name: Run Diffscrape | |
working-directory: ./packages/diffscrape | |
run: | | |
dart run diffscrape \ | |
--uri "https://dart.dev/tools/linter-rules/all" \ | |
--file "../altive_lints/lib/all_lint_rules.yaml" \ | |
--query-selector "pre code" \ | |
--verbose | |
- name: Check for changes | |
id: check_diff | |
run: | | |
diff_count=$(git diff --name-only --relative=packages/altive_lints/lib | wc -l) | |
echo "diff_count=$diff_count" >> "$GITHUB_ENV" | |
if [ "$diff_count" -ne "0" ]; then | |
echo "has_diff=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "has_diff=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Create branch, configure git, commit & push | |
if: env.diff_count != '0' | |
run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git switch -c ${{ env.branch }} | |
git add . | |
git commit -m "feat: update all_lint_rules" | |
git push origin ${{ env.branch }} | |
pull-request: | |
name: Create Pull-Request | |
runs-on: ubuntu-latest | |
needs: update | |
if: needs.update.outputs.has_diff == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate GitHub App token | |
id: generate_token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.PR_WRITER_APP_ID }} | |
private-key: ${{ secrets.PR_WRITER_PRIVATE_KEY }} | |
- name: Create PR | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
run: | | |
gh pr create \ | |
--base "$GITHUB_REF" \ | |
--head ${{ env.branch }} \ | |
--title "feat: Update all lint rules" \ | |
--body "Automated pull request to update lint rules." \ | |
--assignee "$GITHUB_ACTOR" | |
- name: Revoke GitHub Apps token | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
run: | | |
curl --location --silent --request DELETE \ | |
--url "${GITHUB_API_URL}/installation/token" \ | |
--header "Accept: application/vnd.github+json" \ | |
--header "X-GitHub-Api-Version: 2022-11-28" \ | |
--header "Authorization: Bearer ${GITHUB_TOKEN}" |