Repository navigation
Shared CI and Dependabot auto-merge #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: cargo | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| commit-message: | ||
| prefix: ":arrow_up:" | ||
| - package-ecosystem: github-actions | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| commit-message: | ||
| prefix: ":arrow_up:" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout 🛎️ | ||
| uses: actions/checkout@v3 | ||
| uses: actions/checkout@v7 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin deployment checkout to a full commit SHA.
Based on learnings, action tags should be pinned to full commit SHAs. 🧰 Tools
|
||
|
|
||
| - name: Install and Build 🔧 | ||
| run: | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,27 @@ | ||
| name: CI | ||
|
|
||
| on: [push, pull_request] | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| check: | ||
| name: Rust project | ||
| ci: | ||
| name: CI | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Install latest nightly | ||
| uses: actions-rs/toolchain@v1 | ||
| - uses: actions/checkout@v7 | ||
| - uses: dtolnay/rust-toolchain@stable | ||
|
Comment on lines
+19
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin the CI actions to immutable commits.
Based on learnings, action tags and branches are mutable and should be pinned to full commit SHAs. Also applies to: 23-23 🧰 Tools
|
||
| with: | ||
| toolchain: nightly | ||
| override: true | ||
| components: clippy, rustfmt | ||
|
|
||
| - name: Run clippy | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: clippy | ||
|
|
||
| - name: Run fmt | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: fmt | ||
| args: --all -- --check | ||
| - uses: Swatinem/rust-cache@v2 | ||
| - run: cargo fmt --all --check | ||
| - run: cargo clippy --workspace --all-targets -- -D warnings | ||
| - run: cargo build --workspace | ||
| - run: cargo test --workspace | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Dependabot Auto Merge | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| dependabot-auto-merge: | ||
| name: Dependabot Auto Merge | ||
| runs-on: ubuntu-latest | ||
|
|
||
| if: >- | ||
| github.event.pull_request.user.login == 'dependabot[bot]' | ||
|
|
||
| steps: | ||
| # Every update type, majors included: the ruleset's required CI check decides | ||
| # whether it actually merges (auto-merge waits for it). | ||
| # | ||
| # The built-in token can never merge a PR that edits .github/workflows/* | ||
| # ("refusing to allow a GitHub App to create or update workflow ... without workflows | ||
| # permission"), which is what Dependabot's action-version bumps are. Those are left for a | ||
| # human or the sweep tool instead of failing this job. | ||
| - name: Enable auto-merge | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| run: | | ||
| if gh pr diff "$PR_URL" --name-only | grep -q '^\.github/workflows/'; then | ||
| echo "::notice::This PR edits workflow files, which the built-in token cannot merge. Merge it by hand." | ||
| exit 0 | ||
| fi | ||
| gh pr merge --auto --squash "$PR_URL" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pin release checkout to a full commit SHA.
actions/checkout@v7remains a mutable reference in a release job. Pin the reviewed checkout commit so a later tag change cannot alter the action executed before the token-bearing release step. (docs.github.com)Based on learnings, action tags should be pinned to full commit SHAs.
🧰 Tools
🪛 zizmor (1.30.1)
[warning] 23-23: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 9-30: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
Source: Learnings