33
33
if : github.event_name != 'schedule' || github.repository == 'nix-community/nixvim'
34
34
env :
35
35
repo : ${{ github.repository }}
36
- branch : update/${{ github.ref_name }}
36
+ base_branch : ${{ github.ref_name }}
37
+ pr_branch : update/${{ github.ref_name }}
37
38
38
39
steps :
39
40
- name : Checkout repository
59
60
run : |
60
61
# Query for info about the already open update PR
61
62
info=$(
62
- gh api graphql -F owner='{owner}' -F repo='{repo}' -F branch="$branch " -f query='
63
+ gh api graphql -F owner='{owner}' -F repo='{repo}' -F branch="$pr_branch " -f query='
63
64
query($owner:String!, $repo:String!, $branch:String!) {
64
65
repository(owner: $owner, name: $repo) {
65
66
pullRequests(first: 1, states: OPEN, headRefName: $branch) {
98
99
fi
99
100
100
101
- name : Check if nixpkgs input was changed
101
- # The check is run only on scheduled runs & when there is a PR already open
102
- if : github.event_name == 'schedule' && steps.open_pr_info.outputs.number
102
+ # The check is run only on scheduled runs
103
+ if : github.event_name == 'schedule'
103
104
env :
104
105
pr_num : ${{ steps.open_pr_info.outputs.number }}
105
106
pr_url : ${{ steps.open_pr_info.outputs.url }}
@@ -113,8 +114,15 @@ jobs:
113
114
getNixpkgsRev() {
114
115
getAttr "$1" 'inputs.nixpkgs.rev'
115
116
}
116
- old=$(getNixpkgsRev "github:$repo/$branch")
117
+
118
+ if [[ -n "$pr_num" ]]; then
119
+ old_branch=$pr_branch
120
+ else
121
+ old_branch=$base_branch
122
+ fi
123
+ old=$(getNixpkgsRev "github:$repo/$old_branch")
117
124
new=$(getNixpkgsRev "$PWD")
125
+
118
126
if [[ "$old" = "$new" ]]; then
119
127
(
120
128
echo "nixpkgs rev has not changed ($new). Stopping..."
@@ -123,8 +131,13 @@ jobs:
123
131
(
124
132
echo '## Update cancelled'
125
133
echo
126
- echo -n 'The `nixpkgs` input has not changed compared to the already open PR: '
127
- echo -n "[#$pr_num]($pr_url) (\`nixpkgs.rev: $new\`)."
134
+ if [[ -n "$pr_num" ]]; then
135
+ echo -n 'The `nixpkgs` input has not changed compared to the already open PR: '
136
+ echo "[#$pr_num]($pr_url) (\`nixpkgs.rev: $new\`)."
137
+ else
138
+ echo -n 'The `nixpkgs` input has not changed compared to the base branch: '
139
+ echo "\`$base_branch\`"
140
+ fi
128
141
echo
129
142
echo 'The following changes would have been made:'
130
143
echo '```'
@@ -165,7 +178,7 @@ jobs:
165
178
uses : peter-evans/create-pull-request@v6
166
179
with :
167
180
add-paths : " !**"
168
- branch : update/${{ github.ref_name }}
181
+ pr_branch : update/${{ github.ref_name }}
169
182
delete-branch : true
170
183
title : |
171
184
[${{ github.ref_name }}] Update flake.lock & generated files
0 commit comments