Update all lint rules #15
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" | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
outputs: | |
has_diff: ${{ steps.output.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: output diff | |
id: output | |
run: echo "diff_count=$(git diff --name-only --relative=packages/altive_lints/lib | wc -l)" >> "$GITHUB_ENV" | |
- name: Create branch | |
if: env.diff_count != '0' | |
run: | | |
git switch -c ${{ env.branch }} | |
git push origin ${{ env.branch }} | |
- name: Git config | |
if: env.diff_count != '0' | |
run: | | |
git remote set-url origin "https://github-actions:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}" | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
- name: Commit & Push | |
if: env.diff_count != '0' | |
run: | | |
git add . | |
git commit -m "feat: update all_lint_rules" | |
git push origin ${{ env.branch }} | |
- name: Output flag | |
run: echo "has_diff=${{ env.diff_count != '0' }}" >> "$GITHUB_OUTPUT" | |
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 GiHub 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 -B "$GITHUB_REF" -t "${{ env.branch }}" -b "" -a "$GITHUB_ACTOR" -H "${{ env.branch }}" | |
- 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}" |