Skip to content

Commit

Permalink
let's create PRs instead of direct commits (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf authored Jun 4, 2024
1 parent 4f6c9eb commit 7f814d5
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions .github/workflows/flake_vendorhash.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: "Flake vendorHash Updater"
name: "Flake.nix vendorHash updater"
on:
push:
branches:
- main
paths:
- 'go.mod'
- 'go.sum'
- go.mod
- go.sum
workflow_dispatch:
workflow_call:

Expand All @@ -19,20 +19,16 @@ jobs:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
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: Setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
uses: DeterminateSystems/nix-installer-action@v12
- name: Update ocm vendor hash
run: nix run .#nixpkgs.nix-update -- --flake --version=skip ocm
- name: Check diff
Expand All @@ -49,14 +45,29 @@ jobs:
${diff}
\`\`\`
EOF
echo "push='true'" >> $GITHUB_ENV
- name: Push changes
if: github.event.pull_request.head.repo.fork == false && env.push == 'true'
run: |
diff=$(git diff)
if [[ ! -z "$diff" ]]; then
git config --global user.name "ocm-vendorhash"
git config --global user.email "[email protected]"
git commit -am "flake: update ocm vendorHash"
git push
fi
cat << EOF >> "$GITHUB_OUTPUT"
body=\`\`\`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
body: ${{ steps.check-diff.outputs.body }}
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

0 comments on commit 7f814d5

Please sign in to comment.