Update flaskr-ci.yaml

This commit is contained in:
Ted Spinks 2023-02-21 20:08:40 -05:00 committed by GitHub
parent 8b4eb481a9
commit d586f7c557
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,21 +37,23 @@ jobs:
# Required permission to push images with the built-in GITHUB_TOKEN # Required permission to push images with the built-in GITHUB_TOKEN
packages: write packages: write
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
CACHE: "${{ runner.temp }}/.buildx-cache"
NEW_CACHE: "${{ runner.temp }}/.buildx-cache-new"
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set job vars - name: Job vars and prep
id: vars id: vars
run: | run: |
echo "SHA_SHORT=${GITHUB_SHA:0:10}" >> ${GITHUB_ENV} echo "SHA_SHORT=${GITHUB_SHA:0:10}" >> ${GITHUB_ENV}
echo "REPO_LOWER_CASE=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} echo "REPO_LOWER_CASE=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
# This is a separate action that sets up buildx runner mkdir -p ${CACHE}
- name: Set up Docker Buildx - name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
# So now you can use Actions' own caching! - name: Setup cache for Docker Buildx
- name: Cache Docker layers
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: /tmp/.buildx-cache path: ${{ env.CACHE }}
key: flaskr-buildx-${{ github.ref_name }} key: flaskr-buildx-${{ github.ref_name }}
restore-keys: | restore-keys: |
flaskr-buildx-main flaskr-buildx-main
@ -68,8 +70,8 @@ jobs:
push: true push: true
# tags: "ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.sha_short }}" # tags: "ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.sha_short }}"
tags: "ghcr.io/${{ env.REPO_LOWER_CASE }}:${{ env.SHA_SHORT }}" tags: "ghcr.io/${{ env.REPO_LOWER_CASE }}:${{ env.SHA_SHORT }}"
cache-from: type=local,src=/tmp/.buildx-cache cache-from: type=local,src=${{ env.CACHE }}
cache-to: type=local,dest=/tmp/.buildx-cache-new cache-to: type=local,dest=${{ env.NEW_CACHE }}
# This ugly bit is necessary if you don't want your cache to grow forever # This ugly bit is necessary if you don't want your cache to grow forever
# until it hits GitHub's limit of 5GB. # until it hits GitHub's limit of 5GB.
# Temp fix # Temp fix
@ -77,5 +79,5 @@ jobs:
# https://github.com/moby/buildkit/issues/1896 # https://github.com/moby/buildkit/issues/1896
- name: Move cache - name: Move cache
run: | run: |
rm -rf /tmp/.buildx-cache rm -rf $CACHE
mv /tmp/.buildx-cache-new /tmp/.buildx-cache mv $NEW_CACHE $CACHE