From 410863b1867ef2780e0ce65c180635b3406e93fa Mon Sep 17 00:00:00 2001 From: Gyanesh Mishra Date: Fri, 1 Dec 2023 18:05:48 -0800 Subject: [PATCH] try end to end --- .github/workflows/build-soci.yaml | 83 ++++++++++++++++--------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build-soci.yaml b/.github/workflows/build-soci.yaml index 297141b8..1e773ded 100644 --- a/.github/workflows/build-soci.yaml +++ b/.github/workflows/build-soci.yaml @@ -73,51 +73,54 @@ jobs: id: vars run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - # - name: Build Docker image - # uses: docker/build-push-action@v2 - # with: - # context: . - # file: ./Dockerfile # Path to your Dockerfile - # push: false - # tags: ${{ steps.meta.outputs.tags }} - # outputs: type=oci,dest=/tmp/lorax-${{ steps.meta.outputs.version }}.tar + - name: Build Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile # Path to your Dockerfile + push: false # Export to local only + load: true # Will improve future builds + tags: ${{ steps.meta.outputs.tags }} + outputs: type=oci,dest=/tmp/lorax-${{ steps.vars.outputs.sha_short }}.tar - name: Import image in containerd env: tags: ${{ steps.meta.outputs.tags }} short_sha: ${{ steps.vars.outputs.sha_short }} run: | - echo $tags - echo $short_sha - sudo ctr i import --digests /tmp/lorax-${{ steps.meta.outputs.version }}.tar - sudo ctr i ls - # for tag in $tags - # do - # echo "Importing $tag into containerd" - # sudo ctr i import --digests /tmp/lorax-${{ steps.meta.outputs.version }}.tar - # done - # rm -rf /tmp/lorax-${{ steps.meta.outputs.version }}.tar + echo "Importing $sha_short to GHCR" + sudo ctr i import --digests /tmp/lorax-$short_sha.tar + # Delete the on disk copy + rm -rf /tmp/lorax-$short_sha.tar - # - name: Push image with containerd - # env: - # tags: ${{ steps.meta.outputs.tags }} - # short_sha: ${{ steps.vars.outputs.sha_short }} - # run: | - # for tag in $tags - # do - # echo "Pushing $tag to GHCR" - # sudo ctr i push --user "${{ github.repository_owner }}:${{ secrets.GHCR_PAT }}" $tag - # done + - name: Push image with containerd + env: + tags: ${{ steps.meta.outputs.tags }} + run: | + for tag in $tags + do + echo "Pushing $tag to GHCR" + sudo ctr i push --user "${{ github.repository_owner }}:${{ secrets.GHCR_PAT }}" $tag + done + + - name: Create and push soci index + env: + tags: ${{ steps.meta.outputs.tags }} + run: | + for tag in $tags + do + echo "Creating soci index for $tag" + sudo soci create $tag + echo "Pushing soci index for $tag" + sudo soci push --user ${{ github.repository_owner }}:${{ secrets.GHCR_PAT }} $tag + done + + - name: Prune older images + env: + short_sha: ${{ steps.vars.outputs.sha_short }} + run: | + # Delete images older than a week from docker store + docker image prune -a --filter "until=7d" - # - name: Create and push soci index - # env: - # tags: ${{ steps.meta.outputs.tags }} - # short_sha: ${{ steps.vars.outputs.sha_short }} - # run: | - # for tag in $tags - # do - # echo "Creating soci index for $tag" - # sudo soci create $tag - # echo "Pushing soci index for $tag" - # sudo soci push --user ${{ github.repository_owner }}:${{ secrets.GHCR_PAT }} $tag - # done + # Delete the SHA image from containerd store + sudo ctr i rm ghcr.io/predibase/lorax:$short_sha