|
7 | 7 | workflow_dispatch: |
8 | 8 | pull_request: |
9 | 9 | paths: |
10 | | - src/requirements.txt |
| 10 | + - src/requirements.txt |
| 11 | + - 'sql/**.sql' |
11 | 12 | jobs: |
12 | 13 | lint: |
13 | 14 | name: Lint SQL |
14 | 15 | runs-on: ubuntu-latest |
15 | 16 | steps: |
16 | 17 | - name: Checkout Code |
17 | | - uses: actions/checkout@v5 |
| 18 | + uses: actions/checkout@v6 |
18 | 19 | with: |
19 | 20 | # Full git history is needed to get a proper list of changed files within `super-linter` |
20 | 21 | fetch-depth: 0 |
|
23 | 24 | with: |
24 | 25 | python-version: '3.12' |
25 | 26 | - name: Lint SQL code |
26 | | - if: | |
27 | | - github.event_name == 'workflow_dispatch' || |
28 | | - startsWith(github.event.pull_request.title,'Bump sqlfluff') == true |
29 | 27 | run: | |
30 | | - pip install -r src/requirements.txt |
31 | | - sqlfluff lint sql -p 4 |
| 28 | + pip install -r src/requirements.txt -q |
| 29 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ] || \ |
| 30 | + [[ "${{ github.event.pull_request.title }}" == Bump\ sqlfluff* ]]; then |
| 31 | + # Lint all SQL files for workflow_dispatch or sqlfluff bumps |
| 32 | + sqlfluff lint sql -p 4 |
| 33 | + else |
| 34 | + # Lint only changed SQL files |
| 35 | + git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }}...HEAD \ |
| 36 | + | grep '\.sql$' \ |
| 37 | + | xargs -r sqlfluff lint |
| 38 | + fi |
| 39 | +
|
| 40 | +
|
| 41 | + dependabot: |
| 42 | + name: Dependabot auto-merge |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: lint |
| 45 | + if: | |
| 46 | + github.event.pull_request.user.login == 'dependabot[bot]' && |
| 47 | + github.repository == 'HTTPArchive/almanac.httparchive.org' |
| 48 | +
|
| 49 | + permissions: |
| 50 | + contents: write |
| 51 | + pull-requests: write |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Dependabot metadata |
| 55 | + id: metadata |
| 56 | + uses: dependabot/fetch-metadata@v2 |
| 57 | + with: |
| 58 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 59 | + |
| 60 | + - name: Enable auto-merge for Dependabot PRs |
| 61 | + if: | |
| 62 | + ( |
| 63 | + steps.metadata.outputs.update-type == 'version-update:semver-patch' || |
| 64 | + steps.metadata.outputs.update-type == 'version-update:semver-minor' |
| 65 | + ) && contains(steps.metadata.outputs.dependency-names, 'sqlfluff') |
| 66 | + run: gh pr merge --admin --squash "$PR_URL" |
| 67 | + env: |
| 68 | + PR_URL: ${{github.event.pull_request.html_url}} |
| 69 | + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
0 commit comments