Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d1709d60
Commit
d1709d60
authored
Jul 09, 2024
by
Brad Davidson
Committed by
Brad Davidson
Jul 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix INSTALL_K3S_PR support
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
047664b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
13 deletions
+20
-13
install.sh
install.sh
+19
-12
install.sh.sha256sum
install.sh.sha256sum
+1
-1
No files found.
install.sh
View file @
d1709d60
...
@@ -445,7 +445,7 @@ download() {
...
@@ -445,7 +445,7 @@ download() {
download_hash
()
{
download_hash
()
{
if
[
-n
"
${
INSTALL_K3S_PR
}
"
]
;
then
if
[
-n
"
${
INSTALL_K3S_PR
}
"
]
;
then
info
"Downloading hash
${
GITHUB_PR_URL
}
"
info
"Downloading hash
${
GITHUB_PR_URL
}
"
curl
-o
${
TMP_ZIP
}
-H
"Authorization: Bearer
$GITHUB_TOKEN
"
-L
${
GITHUB_PR_URL
}
curl
-
s
-
o
${
TMP_ZIP
}
-H
"Authorization: Bearer
$GITHUB_TOKEN
"
-L
${
GITHUB_PR_URL
}
unzip
-p
${
TMP_ZIP
}
k3s.sha256sum
>
${
TMP_HASH
}
unzip
-p
${
TMP_ZIP
}
k3s.sha256sum
>
${
TMP_HASH
}
else
else
if
[
-n
"
${
INSTALL_K3S_COMMIT
}
"
]
;
then
if
[
-n
"
${
INSTALL_K3S_COMMIT
}
"
]
;
then
...
@@ -481,28 +481,35 @@ get_pr_artifact_url() {
...
@@ -481,28 +481,35 @@ get_pr_artifact_url() {
fatal
"Installing PR builds requires jq"
fatal
"Installing PR builds requires jq"
fi
fi
# Check if unzip is installed
if
!
[
-x
"
$(
command
-v
unzip
)
"
]
;
then
fatal
"Installing PR builds requires unzip"
fi
if
[
-z
"
${
GITHUB_TOKEN
}
"
]
;
then
if
[
-z
"
${
GITHUB_TOKEN
}
"
]
;
then
fatal
"Installing PR builds requires GITHUB_TOKEN with k3s-io/k3s repo permissions"
fatal
"Installing PR builds requires GITHUB_TOKEN with k3s-io/k3s repo permissions"
fi
fi
# GET request to the GitHub API to retrieve the latest commit SHA from the pull request
# GET request to the GitHub API to retrieve the latest commit SHA from the pull request
pr_raw
=
$(
curl
-s
-H
"Authorization: Bearer
$GITHUB_TOKEN
"
"
$github_api_url
/pulls/
$INSTALL_K3S_PR
"
)
set
+e
commit_id
=
$(
curl
-f
-s
-H
"Authorization: Bearer
${
GITHUB_TOKEN
}
"
"
${
github_api_url
}
/pulls/
${
INSTALL_K3S_PR
}
"
| jq
-r
'.head.sha'
)
if
!
echo
"
$pr_raw
"
|
grep
-q
"Bad credentials.*401"
;
then
set
-e
if
[
-z
"
${
commit_id
}
"
]
;
then
fatal
"Installing PR builds requires GITHUB_TOKEN with k3s-io/k3s repo permissions"
fatal
"Installing PR builds requires GITHUB_TOKEN with k3s-io/k3s repo permissions"
fi
fi
commit_id
=
$(
echo
"
$pr_raw
"
| jq
-r
'.head.sha'
)
# GET request to the GitHub API to retrieve the Build workflow associated with the commit
# GET request to the GitHub API to retrieve the Build workflow associated with the commit
wf_raw
=
$(
curl
-s
-H
"Authorization: Bearer
$
GITHUB_TOKEN
"
"
$github_api_url
/commits/
$commit_id
/check-runs"
)
wf_raw
=
$(
curl
-s
-H
"Authorization: Bearer
$
{
GITHUB_TOKEN
}
"
"
${
github_api_url
}
/commits/
${
commit_id
}
/check-runs"
)
build_workflow
=
$(
printf
"%s"
"
$
wf_raw
"
| jq
-r
'.check_runs[] | select(.name == "build / Build")'
)
build_workflow
=
$(
printf
"%s"
"
$
{
wf_raw
}
"
| jq
-r
'.check_runs[] | select(.name == "build / Build")'
)
# Extract the Run ID from the build workflow and lookup artifacts associated with the run
# Extract the Run ID from the build workflow and lookup artifacts associated with the run
run_id
=
$(
echo
"
$
build_workflow
"
| jq
-r
' .details_url'
|
awk
-F
'/'
'{print $(NF-2)}'
|
sort
-rn
|
head
-1
)
run_id
=
$(
echo
"
$
{
build_workflow
}
"
| jq
-r
' .details_url'
|
awk
-F
'/'
'{print $(NF-2)}'
|
sort
-rn
|
head
-1
)
# Extract the artifact ID for the "k3s" artifact
# Extract the artifact ID for the "k3s" artifact
artifacts
=
$(
curl
-s
-H
"Authorization: Bearer
$
GITHUB_TOKEN
"
"
$github_api_url
/actions/runs/
$run_id
/artifacts"
)
artifacts
=
$(
curl
-s
-H
"Authorization: Bearer
$
{
GITHUB_TOKEN
}
"
"
${
github_api_url
}
/actions/runs/
${
run_id
}
/artifacts"
)
artifacts_url
=
$(
echo
"
$
artifacts
"
| jq
-r
'.artifacts[] | select(.name == "k3s") | .archive_download_url'
)
artifacts_url
=
$(
echo
"
$
{
artifacts
}
"
| jq
-r
'.artifacts[] | select(.name == "k3s") | .archive_download_url'
)
GITHUB_PR_URL
=
$artifacts_url
GITHUB_PR_URL
=
"
${
artifacts_url
}
"
}
}
# --- download binary from github url ---
# --- download binary from github url ---
...
@@ -511,7 +518,7 @@ download_binary() {
...
@@ -511,7 +518,7 @@ download_binary() {
# Since Binary and Hash are zipped together, check if TMP_ZIP already exists
# Since Binary and Hash are zipped together, check if TMP_ZIP already exists
if
!
[
-f
${
TMP_ZIP
}
]
;
then
if
!
[
-f
${
TMP_ZIP
}
]
;
then
info
"Downloading K3s artifact
${
GITHUB_PR_URL
}
"
info
"Downloading K3s artifact
${
GITHUB_PR_URL
}
"
curl
-o
${
TMP_ZIP
}
-H
"Authorization: Bearer
$GITHUB_TOKEN
"
-L
${
GITHUB_PR_URL
}
curl
-
s
-f
-
o
${
TMP_ZIP
}
-H
"Authorization: Bearer
$GITHUB_TOKEN
"
-L
${
GITHUB_PR_URL
}
fi
fi
# extract k3s binary from zip
# extract k3s binary from zip
unzip
-p
${
TMP_ZIP
}
k3s
>
${
TMP_BIN
}
unzip
-p
${
TMP_ZIP
}
k3s
>
${
TMP_BIN
}
...
...
install.sh.sha256sum
View file @
d1709d60
2e2469498e1d6a5dcd97d0eeae342298500b27fe0768527ea8039a3295cdbce9
install.sh
a5a95f60c57049a1d4eb11953e60d80f5f7e2fae4c7865959da669b48a44e668
install.sh
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment