mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
ci/update: drop dependency on peter-evans/create-pull-request
We can create/update PRs using the `gh pr` command, no need for a third party dependency.
This commit is contained in:
parent
e4ed227f99
commit
8bf206eb75
1 changed files with 59 additions and 14 deletions
73
.github/workflows/update.yml
vendored
73
.github/workflows/update.yml
vendored
|
@ -39,6 +39,7 @@ jobs:
|
||||||
repo: ${{ github.repository }}
|
repo: ${{ github.repository }}
|
||||||
base_branch: ${{ github.ref_name }}
|
base_branch: ${{ github.ref_name }}
|
||||||
pr_branch: update/${{ github.ref_name }}
|
pr_branch: update/${{ github.ref_name }}
|
||||||
|
team: nix-community/nixvim
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
@ -57,6 +58,11 @@ jobs:
|
||||||
git config user.name 'github-actions[bot]'
|
git config user.name 'github-actions[bot]'
|
||||||
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||||
|
|
||||||
|
- name: Create update branch
|
||||||
|
run: |
|
||||||
|
git branch -D "$pr_branch" || echo "Nothing to delete"
|
||||||
|
git switch -c "$pr_branch"
|
||||||
|
|
||||||
- name: Get info on the current PR
|
- name: Get info on the current PR
|
||||||
id: open_pr_info
|
id: open_pr_info
|
||||||
env:
|
env:
|
||||||
|
@ -161,14 +167,11 @@ jobs:
|
||||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create or Update Pull Request
|
||||||
id: pr
|
id: updated_pr
|
||||||
if: (!steps.changes.outputs.cancelled)
|
if: (!steps.changes.outputs.cancelled)
|
||||||
uses: peter-evans/create-pull-request@v6
|
env:
|
||||||
with:
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
add-paths: "!**"
|
|
||||||
pr_branch: update/${{ github.ref_name }}
|
|
||||||
delete-branch: true
|
|
||||||
title: |
|
title: |
|
||||||
[${{ github.ref_name }}] Update flake.lock & generated files
|
[${{ github.ref_name }}] Update flake.lock & generated files
|
||||||
body: |
|
body: |
|
||||||
|
@ -179,15 +182,57 @@ jobs:
|
||||||
|
|
||||||
## Generate
|
## Generate
|
||||||
${{ steps.generate.outputs.body || 'No changes' }}
|
${{ steps.generate.outputs.body || 'No changes' }}
|
||||||
|
run: |
|
||||||
|
# TODO:
|
||||||
|
# - cherry-pick additional commits from already open PR
|
||||||
|
# - avoid pushing if there are no changes
|
||||||
|
echo "Pushing to remote branch $pr_branch"
|
||||||
|
git push --force --set-upstream origin "$pr_branch"
|
||||||
|
|
||||||
|
if [[ -n "$pr_num" ]]; then
|
||||||
|
echo "Editing existing PR #$pr_num"
|
||||||
|
operation=updated
|
||||||
|
gh pr edit "$pr_num" \
|
||||||
|
--body "$body" \
|
||||||
|
--add-assignee "$team" \
|
||||||
|
--add-reviewer "$team"
|
||||||
|
else
|
||||||
|
echo "Creating new PR"
|
||||||
|
operation=created
|
||||||
|
gh pr create \
|
||||||
|
--base "$base_branch" \
|
||||||
|
--title "$title" \
|
||||||
|
--body "$body" \
|
||||||
|
--assignee "$team" \
|
||||||
|
--reviewer "$team"
|
||||||
|
fi
|
||||||
|
|
||||||
|
pr_info=$(
|
||||||
|
# Get info from `gh pr view`
|
||||||
|
gh pr view --json 'headRefName,number,url' --jq '
|
||||||
|
to_entries[]
|
||||||
|
| .key |=
|
||||||
|
# Rename headRefName -> branch
|
||||||
|
if . == "headRefName" then "branch"
|
||||||
|
else . end
|
||||||
|
| "\(.key)=\(.value)"
|
||||||
|
'
|
||||||
|
# Get additional info locally
|
||||||
|
echo "head=$(git rev-parse HEAD)"
|
||||||
|
echo "operation=$operation"
|
||||||
|
)
|
||||||
|
echo "PR Info:"
|
||||||
|
echo "$pr_info"
|
||||||
|
echo "$pr_info" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Print summary
|
- name: Print summary
|
||||||
if: steps.pr.outputs.pull-request-number
|
if: steps.updated_pr.outputs.number
|
||||||
env:
|
env:
|
||||||
pr_num: ${{ steps.pr.outputs.pull-request-number }}
|
pr_num: ${{ steps.updated_pr.outputs.number }}
|
||||||
pr_url: ${{ steps.pr.outputs.pull-request-url }}
|
pr_url: ${{ steps.updated_pr.outputs.url }}
|
||||||
pr_branch: ${{ steps.pr.outputs.pull-request-branch }}
|
pr_branch: ${{ steps.updated_pr.outputs.branch }}
|
||||||
head: ${{ steps.pr.outputs.pull-request-head-sha }}
|
head: ${{ steps.updated_pr.outputs.head }}
|
||||||
operation: ${{ steps.pr.outputs.pull-request-operation }}
|
operation: ${{ steps.updated_pr.outputs.operation }}
|
||||||
run: |
|
run: |
|
||||||
short=${head:0:6}
|
short=${head:0:6}
|
||||||
# stdout
|
# stdout
|
||||||
|
@ -203,7 +248,7 @@ jobs:
|
||||||
) >> $GITHUB_STEP_SUMMARY
|
) >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
- name: Print cancellation summary
|
- name: Print cancellation summary
|
||||||
if: (!steps.pr.outputs.pull-request-number)
|
if: (!steps.updated_pr.outputs.number)
|
||||||
env:
|
env:
|
||||||
pr_num: ${{ steps.open_pr_info.outputs.number }}
|
pr_num: ${{ steps.open_pr_info.outputs.number }}
|
||||||
pr_url: ${{ steps.open_pr_info.outputs.url }}
|
pr_url: ${{ steps.open_pr_info.outputs.url }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue