From 7d9704af5e7dfa4bfcb2c077024d2b938ff19c70 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Thu, 31 Aug 2023 10:52:46 -0400 Subject: [PATCH] feat: test GHA build caching --- .github/workflows/pull-request.yml | 34 +++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7572c3565..6436b3250 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -36,7 +36,8 @@ jobs: id: tag run: | git_hash=$(git rev-parse --short "$GITHUB_SHA") - image_tag="unraid/api-builder:$git_hash" + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + image_tag="unraid/api-builder:$branch" echo $image_tag echo "tag=$image_tag" >> "$GITHUB_OUTPUT" - uses: docker/setup-buildx-action@v1 @@ -50,6 +51,16 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max provenance: false + - name: Build + uses: docker/build-push-action@v4 + with: + context: api + target: builder + push: false + tags: unraid-api:builder + cache-from: type=gha + cache-to: type=gha,mode=max + provenance: false lint-api: needs: [build] @@ -59,14 +70,21 @@ jobs: working-directory: api runs-on: ubuntu-latest steps: - - name: Download artifact - uses: actions/download-artifact@v3 + - name: Checkout repo + uses: actions/checkout@v3 with: - name: builder - path: /tmp - - name: Load image - run: | - docker load --input /tmp/builder.tar + persist-credentials: true + - uses: docker/setup-buildx-action@v1 + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: api + target: builder + push: false + tags: unraid-api:builder + cache-from: type=gha + cache-to: type=gha,mode=max + provenance: false - name: Lint run: | docker run unraid-api:builder npm run lint