Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ updates:
interval: "daily"
time: "04:00"
timezone: "America/Los_Angeles"
# Hold public-registry version updates for a few days so a malicious or yanked release is
# likely to be caught upstream before it is auto-merged. Security updates ignore cooldown.
# Our own packages are exempt so book content still ships the next day: ContentFeedNuget (private
# feed) and EssentialCSharp.Shared.Models (nuget.org) share $(ToolingPackagesVersion) and move together.
cooldown:
default-days: 3
semver-major-days: 7
exclude:
- "ContentFeedNuget"
- "EssentialCSharp.Shared.Models"
groups:
tooling-dependencies:
applies-to: version-updates
Expand All @@ -36,6 +46,9 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
# github-actions supports only default-days (no semver-*-days).
cooldown:
default-days: 3
ignore:
# gh-aw action pins are compiler-managed and updated with workflow source updates/recompilation.
- dependency-name: "github/gh-aw-actions/*"
Expand All @@ -44,6 +57,9 @@ updates:
directory: "/EssentialCSharp.Web/"
schedule:
interval: "weekly"
cooldown:
default-days: 3
semver-major-days: 7

- package-ecosystem: "docker"
# Look for a `Dockerfile` in the `root` directory
Expand Down
59 changes: 44 additions & 15 deletions .github/workflows/Automerge-ContentNugetFeed.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,62 @@
name: Dependabot auto-merge
on: pull_request

# Every privileged call below uses BOT_PAT; the workflow token needs nothing beyond read.
permissions:
contents: write
pull-requests: write
contents: read

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
# Act only when Dependabot opened the PR, Dependabot's own push started this run, and a re-run
# by anyone else (github.triggering_actor) cannot reuse Dependabot's actor identity.
if: >-
github.event.pull_request.user.login == 'dependabot[bot]' &&
github.actor == 'dependabot[bot]' &&
github.triggering_actor == 'dependabot[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v3
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
with:
github-token: ${{ secrets.BOT_PAT }}

# Approve and merge only the commit this run was triggered for. If anything was pushed to the
# branch after Dependabot's commit, stop instead of approving someone else's code.
- name: Verify the PR head is still the triggering commit
env:
GH_TOKEN: ${{ secrets.BOT_PAT }}
PR_URL: ${{ github.event.pull_request.html_url }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
live_head="$(gh pr view "$PR_URL" --json headRefOid --jq .headRefOid)"
if [ "$live_head" != "$HEAD_SHA" ]; then
echo "::error::PR head is $live_head, but this run was triggered for $HEAD_SHA. Not approving."
exit 1
fi

- name: Add a label for content updates
if: ${{contains(steps.metadata.outputs.dependency-names, 'ContentFeedNuget')}}
if: ${{ contains(steps.metadata.outputs.dependency-names, 'ContentFeedNuget') }}
run: gh pr edit "$PR_URL" --add-label "content update"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{ secrets.BOT_PAT }}
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.BOT_PAT }}

- name: Approve the triggering commit
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.BOT_PAT}}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
GH_TOKEN: ${{ secrets.BOT_PAT }}
PR_NUMBER: ${{ github.event.pull_request.number }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
gh api --method POST "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews" \
-f commit_id="$HEAD_SHA" \
-f event=APPROVE \
-f body="Auto-approved Dependabot update at ${HEAD_SHA}."

- name: Enable auto-merge for the triggering commit
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.BOT_PAT}}
GH_TOKEN: ${{ secrets.BOT_PAT }}
PR_URL: ${{ github.event.pull_request.html_url }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: gh pr merge --auto --squash --delete-branch --match-head-commit "$HEAD_SHA" "$PR_URL"
Loading
Loading