Skip to content

Commit

Permalink
Impl triggering beta images build via GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Oct 20, 2019
1 parent 7c184fc commit ba1292f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ trim_trailing_whitespace = false
indent_style = space
indent_size = 4

[post_push]
[{post_push, *.sh}]
indent_style = space
indent_size = 2

[*.{yml,yaml}]
indent_style = space
indent_size = 2
30 changes: 30 additions & 0 deletions .github/workflows/trigger-beta-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Trigger beta images build

on:
schedule:
- cron: '10 5 * * *'
#push:
# branches: ["dev"]

jobs:
trigger:
runs-on: ubuntu-latest

strategy:
matrix:
os:
- alpine3.10
- buster
- buster-slim
- stretch
- stretch-slim

steps:
- uses: actions/checkout@master
with:
ref: ${{ github.ref }}

- run: bash ./check-and-trigger-beta-builds.sh
env:
IMAGE_OS: ${{ matrix.os }}
TRIGGER_TOKEN: ${{ secrets.BETA_TRIGGER_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/.idea/
/*.iml
.DS_Store

/*-beta.toml
39 changes: 39 additions & 0 deletions check-and-trigger-beta-builds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash


if [ -z "$IMAGE_OS" ]; then
echo "error: No IMAGE_OS env var provided"
exit 1
fi
if [ -z "$TRIGGER_TOKEN" ]; then
echo "error: No TRIGGER_TOKEN env var provided"
exit 1
fi


set -e

curl -fL -o ./channel-rust-beta.toml \
https://static.rust-lang.org/dist/channel-rust-beta.toml
currentToolchainVer=$(grep -A1 '\[pkg.rustc]' channel-rust-beta.toml \
| grep version \
| cut -d '"' -f2 \
| tr -d "\n")
echo "--> Current toolchain version: rustc $currentToolchainVer"

docker pull instrumentisto/rust:beta-$IMAGE_OS
latestImageVer=$(docker run --rm instrumentisto/rust:beta-$IMAGE_OS \
rustc -V \
| tr -d "\n")
echo "--> Latest image version: $latestImageVer"

if [ "rustc $currentToolchainVer" != "$latestImageVer" ]; then
curl -sS -H "Content-Type: application/json" \
--data "{\"build\":true,\"docker_tag\":\"beta-$IMAGE_OS\"}" \
-X POST \
https://cloud.docker.com/api/build/v1/source/$TRIGGER_TOKEN/call/ \
>/dev/null \
&& echo "--> Build trigerred"
else
echo "--> Image is up-to-date, no need to trigger build"
fi

0 comments on commit ba1292f

Please sign in to comment.