Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(gha): get docker builds working #2

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ on:
push:
branches:
- main
- gha-release-2
paths-ignore:
- README.md
- .buildkite/**
- .github/**
- docker-compose.yml
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: write
packages: write

steps:
- name: login to ghcr.io
Expand All @@ -28,20 +31,24 @@ jobs:
with:
fetch-depth: 0

- name: Update README.md
- name: Calculate new version with autotag
run: |
curl -sL https://git.io/autotag-install | sh -s -- -b "${RUNNER_TEMP}/bin"
set -x
version=$(${RUNNER_TEMP}/bin/autotag -n)
echo "version=$version" >> $GITHUB_ENV

- name: Update version in README.md and hooks/pre-command
run: |
sed -i'' -Ee "s/telemetry#v(.*):/telemetry#v${version}:/" README.md
sed -i'' -Ee "s/TAG=\"v(.*)\"/TAG=\"v${version}\"/" hooks/pre-command

- name: Commit README.md
- name: Commit changes
uses: planetscale/ghcommit-action@c7915d6c18d5ce4eb42b0eff3f10a29fe0766e4c # v0.1.44
with:
commit_message: "🤖 Update README.md"
commit_message: "🤖 Update version tag"
repo: ${{ github.repository }}
branch: ${{ github.head_ref || github.ref_name }}
file_pattern: README.md
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Expand Down
6 changes: 6 additions & 0 deletions hooks/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
BUILDKITE_TELEMETRY_PLUGIN_TMPDIR=$(mktemp -d)
BUILDKITE_TELEMETRY_PLUGIN_OUTFILE="${BUILDKITE_TELEMETRY_PLUGIN_TMPDIR}/out.txt"

export BUILDKITE_TELEMETRY_PLUGIN_TMPDIR
export BUILDKITE_TELEMETRY_PLUGIN_OUTFILE
3 changes: 1 addition & 2 deletions hooks/post-command
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
set -eou pipefail
#set -x

# TODO: proper tempdir scoped to this invocation
docker stop -t1 telemetry-plugin

docker stop -t1 dstat
echo "+++ :bar_chart: Telemetry:"
cat "$BUILDKITE_TELEMETRY_PLUGIN_OUTFILE"

Expand Down
8 changes: 4 additions & 4 deletions hooks/pre-command
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/usr/bin/env bash

set -eou pipefail
set -x
#set -x

# TODO: proper tempdir scoped to this invocation
TAG="v0.0.0"

docker run \
--rm \
--init \
--detach \
--name dstat \
--name telemetry-plugin \
--pid host \
--net host \
--userns host \
-v "$BUILDKITE_TELEMETRY_PLUGIN_TMPDIR:$BUILDKITE_TELEMETRY_PLUGIN_TMPDIR" \
ghcr.io/planetscale/telemetry-buildkite-plugin:latest \
ghcr.io/planetscale/telemetry-buildkite-plugin:"$TAG" \
"dstat -t -c -m -n --disk-tps --disk --color --noupdate 10 > $BUILDKITE_TELEMETRY_PLUGIN_OUTFILE"

docker ps -a