From fce3672bc14e7eac2902866fac99f9654f7bb543 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sat, 18 Jun 2022 20:23:23 -0700 Subject: [PATCH] Add nightly build action that uses Earthly. Another step in #1953 --- .github/workflows/docker-nightly-earthly.yaml | 40 +++++++++++++++++++ build/release/docker-nightly-earthly.sh | 13 ++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/docker-nightly-earthly.yaml create mode 100755 build/release/docker-nightly-earthly.sh diff --git a/.github/workflows/docker-nightly-earthly.yaml b/.github/workflows/docker-nightly-earthly.yaml new file mode 100644 index 000000000..e1bdb662f --- /dev/null +++ b/.github/workflows/docker-nightly-earthly.yaml @@ -0,0 +1,40 @@ +# See https://docs.earthly.dev/ci-integration/vendor-specific-guides/gh-actions-integration +# for details. + +name: Build nightly docker + +on: + workflow_dispatch: + schedule: + - cron: '0 2 * * *' + +jobs: + Docker: + runs-on: ubuntu-latest + steps: + - name: Download latest earthly + run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.6.14/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" + + - name: Earthly version + run: earthly --version + + - name: Log into GitHub Container Registry + env: + GH_CR_PAT: ${{ secrets.GH_CR_PAT }} + run: echo "${{ secrets.GH_CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin + if: env.GH_CR_PAT != null + + - uses: actions/checkout@v3 + - name: Checkout and build + if: env.GH_CR_PAT != null + env: + GH_CR_PAT: ${{ secrets.GH_CR_PAT }} + run: | + branch="" + if [ -n "$GITHUB_HEAD_REF" ]; then + branch="$GITHUB_HEAD_REF" + else + branch="${GITHUB_REF##*/}" + fi + git checkout -b "$branch" || true + cd build/release && ./docker-nightly-earthly.sh diff --git a/build/release/docker-nightly-earthly.sh b/build/release/docker-nightly-earthly.sh new file mode 100755 index 000000000..523d79720 --- /dev/null +++ b/build/release/docker-nightly-earthly.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Docker build +# Must authenticate first: https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages#authenticating-to-github-packages +DOCKER_IMAGE="owncast-earthly" +DATE=$(date +"%Y%m%d") +VERSION="${DATE}-nightly" + +echo "Building Docker image ${DOCKER_IMAGE}..." + +earthly --ci --push +docker --image="ghcr.io/owncast/${DOCKER_IMAGE}" --tag=nightly --version=${VERSION} + +# docker push ghcr.io/owncast/${DOCKER_IMAGE}:nightly