Skip to content

Commit fb67a71

Browse files
committed
[ci] fail job on error http codes and add some debug output
1 parent ba45641 commit fb67a71

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

ci/archive-job-log.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
#!/bin/bash
2-
set -e
2+
set -ex
3+
4+
function log() {
5+
echo "$1" >&2
6+
}
37

48
job_id="$1"
5-
raw_log_url=$(curl -Ls -o /dev/null \
9+
api_url="https://api.github.com/repos/$GITHUB_REPOSITORY/actions/jobs/$job_id/logs"
10+
log "$api_url"
11+
12+
raw_log_url=$(curl -Ls --fail --show-error -o /dev/null \
613
-w %{url_effective} \
714
-H "Accept: application/vnd.github+json" \
815
-H "Authorization: Bearer $GITHUB_TOKEN" \
916
-H "X-GitHub-Api-Version: 2022-11-28" \
10-
https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/jobs/$job_id/logs
17+
"$api_url"
1118
)
12-
archived_url=$(curl -L -s -o /dev/null -w "%header{link}" "http://web.archive.org/save/$raw_log_url" \
19+
archived_url=$(curl -L -s --fail --show-error -o /dev/null -w "%header{link}" "http://web.archive.org/save/$raw_log_url" \
1320
| awk '/^</ {
1421
split($0, links, ",")
15-
22+
1623
for(i=1; i<=length(links); i++) {
1724
link = links[i]
18-
25+
1926
gsub(/<|>/, "", link) # remove angle brackets
2027
gsub(/^ *| *$/, "", link) # remove leading/trailing whitespace
21-
28+
2229
if(link ~ "rel=\"memento\"") {
2330
split(link, parts, ";")
2431
gsub(/^http:/, "https:", parts[1])

ci/create-job-outputs.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
#!/bin/bash
2+
set -e
3+
4+
function log() {
5+
echo "$1" >&2
6+
}
27

38
job_name=Publish
49
step_name="Create Checksums"
5-
job=$(curl -Ls \
6-
-H "Accept: application/vnd.github+json" \
7-
-H "Authorization: Bearer $GITHUB_TOKEN"\
8-
-H "X-GitHub-Api-Version: 2022-11-28" \
9-
https://api.github.com/repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/attempts/$GITHUB_RUN_ATTEMPT/jobs \
10-
| jq -r ".jobs[] | select(.name==\"$job_name\")"
11-
)
10+
api_url="/repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/attempts/$GITHUB_RUN_ATTEMPT/jobs"
11+
log "$api_url"
12+
13+
job=$(gh api "$api_url" --jq ".jobs[] | select(.name==\"$job_name\")")
14+
[[ -z "$job" ]] && { log "Job '$job_name' not found"; exit 1; }
15+
1216
run_url=$(echo "$job" | jq -r .html_url)
1317
checksum_number=$(echo "$job" | jq ".steps[] | select(.name==\"$step_name\") | .number")
18+
[[ -z "$checksum_number" ]] && { log "Step '$step_name'.number not found"; exit 1; }
1419

1520
echo "checksum_url=$run_url#step:$checksum_number:1"
1621
echo "job_id=$GITHUB_JOB"

0 commit comments

Comments
 (0)