mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
ci/update: check against base branch if no PR is open
This commit is contained in:
parent
635adc07fa
commit
c3d95240c4
1 changed files with 21 additions and 8 deletions
29
.github/workflows/update.yml
vendored
29
.github/workflows/update.yml
vendored
|
@ -33,7 +33,8 @@ jobs:
|
||||||
if: github.event_name != 'schedule' || github.repository == 'nix-community/nixvim'
|
if: github.event_name != 'schedule' || github.repository == 'nix-community/nixvim'
|
||||||
env:
|
env:
|
||||||
repo: ${{ github.repository }}
|
repo: ${{ github.repository }}
|
||||||
branch: update/${{ github.ref_name }}
|
base_branch: ${{ github.ref_name }}
|
||||||
|
pr_branch: update/${{ github.ref_name }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
@ -59,7 +60,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
# Query for info about the already open update PR
|
# Query for info about the already open update PR
|
||||||
info=$(
|
info=$(
|
||||||
gh api graphql -F owner='{owner}' -F repo='{repo}' -F branch="$branch" -f query='
|
gh api graphql -F owner='{owner}' -F repo='{repo}' -F branch="$pr_branch" -f query='
|
||||||
query($owner:String!, $repo:String!, $branch:String!) {
|
query($owner:String!, $repo:String!, $branch:String!) {
|
||||||
repository(owner: $owner, name: $repo) {
|
repository(owner: $owner, name: $repo) {
|
||||||
pullRequests(first: 1, states: OPEN, headRefName: $branch) {
|
pullRequests(first: 1, states: OPEN, headRefName: $branch) {
|
||||||
|
@ -98,8 +99,8 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check if nixpkgs input was changed
|
- name: Check if nixpkgs input was changed
|
||||||
# The check is run only on scheduled runs & when there is a PR already open
|
# The check is run only on scheduled runs
|
||||||
if: github.event_name == 'schedule' && steps.open_pr_info.outputs.number
|
if: github.event_name == 'schedule'
|
||||||
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 }}
|
||||||
|
@ -113,8 +114,15 @@ jobs:
|
||||||
getNixpkgsRev() {
|
getNixpkgsRev() {
|
||||||
getAttr "$1" 'inputs.nixpkgs.rev'
|
getAttr "$1" 'inputs.nixpkgs.rev'
|
||||||
}
|
}
|
||||||
old=$(getNixpkgsRev "github:$repo/$branch")
|
|
||||||
|
if [[ -n "$pr_num" ]]; then
|
||||||
|
old_branch=$pr_branch
|
||||||
|
else
|
||||||
|
old_branch=$base_branch
|
||||||
|
fi
|
||||||
|
old=$(getNixpkgsRev "github:$repo/$old_branch")
|
||||||
new=$(getNixpkgsRev "$PWD")
|
new=$(getNixpkgsRev "$PWD")
|
||||||
|
|
||||||
if [[ "$old" = "$new" ]]; then
|
if [[ "$old" = "$new" ]]; then
|
||||||
(
|
(
|
||||||
echo "nixpkgs rev has not changed ($new). Stopping..."
|
echo "nixpkgs rev has not changed ($new). Stopping..."
|
||||||
|
@ -123,8 +131,13 @@ jobs:
|
||||||
(
|
(
|
||||||
echo '## Update cancelled'
|
echo '## Update cancelled'
|
||||||
echo
|
echo
|
||||||
echo -n 'The `nixpkgs` input has not changed compared to the already open PR: '
|
if [[ -n "$pr_num" ]]; then
|
||||||
echo -n "[#$pr_num]($pr_url) (\`nixpkgs.rev: $new\`)."
|
echo -n 'The `nixpkgs` input has not changed compared to the already open PR: '
|
||||||
|
echo "[#$pr_num]($pr_url) (\`nixpkgs.rev: $new\`)."
|
||||||
|
else
|
||||||
|
echo -n 'The `nixpkgs` input has not changed compared to the base branch: '
|
||||||
|
echo "\`$base_branch\`"
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
echo 'The following changes would have been made:'
|
echo 'The following changes would have been made:'
|
||||||
echo '```'
|
echo '```'
|
||||||
|
@ -165,7 +178,7 @@ jobs:
|
||||||
uses: peter-evans/create-pull-request@v6
|
uses: peter-evans/create-pull-request@v6
|
||||||
with:
|
with:
|
||||||
add-paths: "!**"
|
add-paths: "!**"
|
||||||
branch: update/${{ github.ref_name }}
|
pr_branch: update/${{ github.ref_name }}
|
||||||
delete-branch: true
|
delete-branch: true
|
||||||
title: |
|
title: |
|
||||||
[${{ github.ref_name }}] Update flake.lock & generated files
|
[${{ github.ref_name }}] Update flake.lock & generated files
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue