diff --git a/.editorconfig b/.editorconfig index 7530074..d4b0291 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/.github/workflows/trigger-beta-build.yml b/.github/workflows/trigger-beta-build.yml new file mode 100644 index 0000000..dc722ca --- /dev/null +++ b/.github/workflows/trigger-beta-build.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index 38c4cfb..fcf0996 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /.idea/ /*.iml .DS_Store + +/*-beta.toml diff --git a/check-and-trigger-beta-builds.sh b/check-and-trigger-beta-builds.sh new file mode 100644 index 0000000..5ddaf65 --- /dev/null +++ b/check-and-trigger-beta-builds.sh @@ -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