Flake.nix vendorHash updater #6
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: "Flake.nix vendorHash updater" | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- go.mod | |
- go.sum | |
workflow_dispatch: | |
workflow_call: | |
jobs: | |
updateVendorHash: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Generate token | |
id: generate_token | |
uses: tibdex/github-app-token@v2 | |
with: # OCMBot | |
app_id: ${{ secrets.OCMBOT_APP_ID }} | |
private_key: ${{ secrets.OCMBOT_PRIV_KEY }} | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.generate_token.outputs.token }} | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@v12 | |
- name: Update ocm vendor hash | |
run: nix run .#nixpkgs.nix-update -- --flake --version=skip ocm | |
- name: Check diff | |
id: check-diff | |
run: | | |
diff=$(git diff) | |
if [[ -z "$diff" ]]; then | |
echo "Everything is tidy." | |
exit 0 | |
fi | |
cat << EOF >> "${GITHUB_STEP_SUMMARY}" | |
\`\`\`diff | |
${diff} | |
\`\`\` | |
EOF | |
- name: Create pull request | |
id: create_pull_request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
commit-message: update vendorHash | |
title: Update vendorHash in flake.nix | |
branch: nix/flake | |
committer: OCMBot <[email protected]> | |
add-paths: | | |
flake.nix | |
flake.lock | |
- name: Enable pull request auto merge | |
if: ${{ steps.create_pull_request.outputs.pull-request-number }} | |
uses: peter-evans/enable-pull-request-automerge@v3 | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
pull-request-number: ${{ steps.create_pull_request.outputs.pull-request-number }} | |
merge-method: squash |