From f1228c3fd334be8b672ed4713a86b04eb1d5042d Mon Sep 17 00:00:00 2001 From: Joseph Lombrozo Date: Thu, 17 Aug 2023 21:56:10 -0400 Subject: [PATCH] support building an image for prs (#56) --- .github/workflows/on_pull_request.yaml | 30 ++++++++++++++++--- ...{on_tag.yaml => on_release_published.yaml} | 0 Earthfile | 1 - 3 files changed, 26 insertions(+), 5 deletions(-) rename .github/workflows/{on_tag.yaml => on_release_published.yaml} (100%) diff --git a/.github/workflows/on_pull_request.yaml b/.github/workflows/on_pull_request.yaml index f37c52b0..eff69404 100644 --- a/.github/workflows/on_pull_request.yaml +++ b/.github/workflows/on_pull_request.yaml @@ -1,20 +1,29 @@ name: pr_build + on: pull_request: paths: - '*' - '*/**' - '!README.md' - - '!.tool-versions' - '!COPYING.LGPL-3' - '!.gitattributes' - '!.gitignore' +env: + FS_IMAGE: ttl.sh/${{ github.repository }}/pr-${{ github.event.pull_request.number }}/${{ github.event.pull_request.head.sha }} + FS_TAG: 24h + # TODO: Move this to repo config jobs: build: runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + pull-requests: write + strategy: matrix: platform: @@ -38,13 +47,26 @@ jobs: # Reads in .tools-versions and spits out env variables - uses: wistia/parse-tool-versions@v1.0 + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: earthly/actions-setup@v1 with: { version: "v${{ env.EARTHLY_TOOL_VERSION }}" } - run: | earthly \ + --push \ --platform ${{ matrix.platform }} \ - +docker \ + +docker-tag \ --GIT_COMMIT=${{ env.GIT_SHA_SHORT }} \ - --GIT_TAG=mr \ - --GOLANG_VERSION=${{ env.GOLANG_TOOL_VERSION }} + --GIT_TAG=${{ env.FS_TAG }} \ + --GOLANG_VERSION=${{ env.GOLANG_TOOL_VERSION }} \ + --CI_REGISTRY_IMAGE=${{ env.FS_IMAGE }} + + - uses: mshick/add-pr-comment@v2 + with: + message: | + Temporary image available at `${{ env.FS_IMAGE }}:${{ env.FS_TAG }}` for 24 hours. If you need another built, close and reopen the PR. diff --git a/.github/workflows/on_tag.yaml b/.github/workflows/on_release_published.yaml similarity index 100% rename from .github/workflows/on_tag.yaml rename to .github/workflows/on_release_published.yaml diff --git a/Earthfile b/Earthfile index ba57d53d..935f62e5 100644 --- a/Earthfile +++ b/Earthfile @@ -124,7 +124,6 @@ docker-tag: ARG CI_REGISTRY_IMAGE="ghcr.io/zapier/kubechecks" ARG --required GIT_TAG - SAVE IMAGE --push $CI_REGISTRY_IMAGE:latest SAVE IMAGE --push $CI_REGISTRY_IMAGE:$GIT_TAG dlv: