Skip to content

Commit

Permalink
Curl for the link to the CI build result page
Browse files Browse the repository at this point in the history
  • Loading branch information
stagnation committed Nov 17, 2023
1 parent 68c2fad commit 464be45
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ Binaries can be found under the CI Build link,
at the top right in the GitHub Actions page.

| Application | Repository | Commit Timestamp | Container Image | CI Build |
| ------------------- | ----------------------------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| bb-browser | [bb-browser](https://github.com/buildbarn/bb-browser) | 2023-11-03 13:42:27 UTC | [ghcr.io/buildbarn/bb-storage:20231111T202247Z-ece87ab](ghcr.io/buildbarn/bb-storage:20231111T202247Z-ece87ab) | [`794e38071d7a18babfc6c57643767d26415dcd63`](https://github.com/buildbarn/bb-browser/commit/794e38071d7a18babfc6c57643767d26415dcd63/checks) |
| bb-runner-installer | [bb-remote-execution](https://github.com/buildbarn/bb-remote-execution) | 2023-11-14 14:07:35 UTC | [ghcr.io/buildbarn/bb-runner-installer:20231114T140735Z-33a0262](ghcr.io/buildbarn/bb-runner-installer:20231114T140735Z-33a0262) | [`33a02620cd6efedf4963143a930df009f93493b5`](https://github.com/buildbarn/bb-remote-execution/commit/33a02620cd6efedf4963143a930df009f93493b5/checks) |
| bb-scheduler | [bb-remote-execution](https://github.com/buildbarn/bb-remote-execution) | 2023-11-14 14:07:35 UTC | [ghcr.io/buildbarn/bb-scheduler:20231114T140735Z-33a0262](ghcr.io/buildbarn/bb-scheduler:20231114T140735Z-33a0262) | [`33a02620cd6efedf4963143a930df009f93493b5`](https://github.com/buildbarn/bb-remote-execution/commit/33a02620cd6efedf4963143a930df009f93493b5/checks) |
| bb-worker | [bb-remote-execution](https://github.com/buildbarn/bb-remote-execution) | 2023-11-14 14:07:35 UTC | [ghcr.io/buildbarn/bb-worker:20231114T140735Z-33a0262](ghcr.io/buildbarn/bb-worker:20231114T140735Z-33a0262) | [`33a02620cd6efedf4963143a930df009f93493b5`](https://github.com/buildbarn/bb-remote-execution/commit/33a02620cd6efedf4963143a930df009f93493b5/checks) |
| bb-storage | [bb-storage](https://github.com/buildbarn/bb-storage) | 2023-11-11 20:22:47 UTC | [ghcr.io/buildbarn/bb-storage:20231111T202247Z-ece87ab](ghcr.io/buildbarn/bb-storage:20231111T202247Z-ece87ab) | [`ece87ab6dc2a9e1e592d2032f5a02c3694765cfc`](https://github.com/buildbarn/bb-storage/commit/ece87ab6dc2a9e1e592d2032f5a02c3694765cfc/checks) |
| ------------------- | ----------------------------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -----------------------------------------------------------------------------------------------------------------------|
| bb-browser | [bb-browser](https://github.com/buildbarn/bb-browser) | 2023-11-03 13:42:27 UTC | [ghcr.io/buildbarn/bb-storage:20231111T202247Z-ece87ab](ghcr.io/buildbarn/bb-storage:20231111T202247Z-ece87ab) | [`794e38071d7a18babfc6c57643767d26415dcd63`](https://github.com/buildbarn/bb-browser/actions/runs/6745964234) |
| bb-runner-installer | [bb-remote-execution](https://github.com/buildbarn/bb-remote-execution) | 2023-11-14 14:07:35 UTC | [ghcr.io/buildbarn/bb-runner-installer:20231114T140735Z-33a0262](ghcr.io/buildbarn/bb-runner-installer:20231114T140735Z-33a0262) | [`33a02620cd6efedf4963143a930df009f93493b5`](https://github.com/buildbarn/bb-remote-execution/actions/runs/6864755846) |
| bb-scheduler | [bb-remote-execution](https://github.com/buildbarn/bb-remote-execution) | 2023-11-14 14:07:35 UTC | [ghcr.io/buildbarn/bb-scheduler:20231114T140735Z-33a0262](ghcr.io/buildbarn/bb-scheduler:20231114T140735Z-33a0262) | [`33a02620cd6efedf4963143a930df009f93493b5`](https://github.com/buildbarn/bb-remote-execution/actions/runs/6864755846) |
| bb-worker | [bb-remote-execution](https://github.com/buildbarn/bb-remote-execution) | 2023-11-14 14:07:35 UTC | [ghcr.io/buildbarn/bb-worker:20231114T140735Z-33a0262](ghcr.io/buildbarn/bb-worker:20231114T140735Z-33a0262) | [`33a02620cd6efedf4963143a930df009f93493b5`](https://github.com/buildbarn/bb-remote-execution/actions/runs/6864755846) |
| bb-storage | [bb-storage](https://github.com/buildbarn/bb-storage) | 2023-11-11 20:22:47 UTC | [ghcr.io/buildbarn/bb-storage:20231111T202247Z-ece87ab](ghcr.io/buildbarn/bb-storage:20231111T202247Z-ece87ab) | [`ece87ab6dc2a9e1e592d2032f5a02c3694765cfc`](https://github.com/buildbarn/bb-storage/actions/runs/6836384126) |

## Changelog

Expand Down
29 changes: 27 additions & 2 deletions tools/update-container-image-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ get_full_git_commit_hash() {
| sed 's#.*<meta property="og:url" content="/buildbarn/'"$repo"'/commit/\([0-9a-f]*\)" />.*#\1#'
}

actions_summary_page() {
checks_url=$1; shift

### The result is a nested span within a `href` tag.
# So we capture each href tag as we pass them,
# and when we see the needle "on: push"
# we can print the last href tag we encountered.
res="$(curl -s "$checks_url" | awk '
{
if ($0 ~/<a href/)
{ link=$0 }
if ($0 ~/on: push/) {
split(link, parts, " ");
href=parts[2]
split(href, parts, "\"");
suffix=parts[2]
print("https://github.com" suffix)
}
}
')"
echo "$res"
}

update_image_version() {
repo="$1"; shift
image_name="$1"; shift
Expand All @@ -42,15 +65,17 @@ update_image_version() {
timestamp=$(echo "$image_version" | sed 's#\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)T\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)Z.*#\1-\2-\3 \4:\5:\6#')
commit_hash=$(get_full_git_commit_hash "$repo")
checks_url="https://github.com/buildbarn/$repo/commit/$commit_hash/checks"
summary_url=$(actions_summary_page "$checks_url")

# Replace image version.
sed -i "s#\(ghcr\.io/buildbarn/$image_name:\)[0-9tzTZ]*-[0-9a-f]*#\1$image_version#g" \
README.md docker-compose/docker-compose.yml kubernetes/*.yaml

# Replace timestamp and CI Build link.
# Replace timestamp and CI build result link.
actions_url_stem="https://github.com/buildbarn/$repo/actions/runs"
sed -i \
-e "s#^\(| $image_name .*| \)\([^|]* UTC |\)#\1$timestamp UTC |#" \
-e "s#| [^|]*/buildbarn/$repo/commit/[0-9a-f]*/checks#| [\`$commit_hash\`]($checks_url#" \
-e "s#| [^|]*$actions_url_stem/[0-9a-f]*#| [\`$commit_hash\`]($summary_url#" \
README.md
}

Expand Down

0 comments on commit 464be45

Please sign in to comment.