Skip to content
Merged
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
64 changes: 64 additions & 0 deletions .github/workflows/dependabot-gomod2nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Update gomod2nix on Dependabot PRs

on:
pull_request:
paths:
- 'go.mod'
- 'go.sum'

permissions:
contents: write
pull-requests: write

jobs:
update-gomod2nix:
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest

steps:
- name: Checkout PR
uses: actions/checkout@v5
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

- name: Run gomod2nix
run: nix develop -c gomod2nix

- name: Check for changes
id: changes
run: |
if git diff --quiet gomod2nix.toml; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Commit and push gomod2nix.toml
if: steps.changes.outputs.changed == 'true'
uses: EndBug/add-and-commit@v9
with:
default_author: user_info
message: "chore: update gomod2nix.toml"
add: 'gomod2nix.toml'

- name: Comment on PR
if: steps.changes.outputs.changed == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ Updated `gomod2nix.toml` automatically via `nix develop -c gomod2nix`'
})
Loading