Skip to content

Commit

Permalink
Separate cache images to a cache package
Browse files Browse the repository at this point in the history
  • Loading branch information
Silex committed Aug 16, 2024
1 parent 9eac077 commit 926ff92
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ runs:
shell: bash
run: |
echo "tags=$(bin/images --json | jq -c '.images[] | select(.version == "${{ inputs.version }}" and .context == "${{ inputs.context }}") | .tags_with_repository')" >> $GITHUB_OUTPUT
echo "cache=$(bin/images --json | jq -c '.images[] | select(.version == "${{ inputs.version }}" and .context == "${{ inputs.context }}") | .cache')" >> $GITHUB_OUTPUT
- name: Build & push images
uses: docker/build-push-action@master
Expand All @@ -40,5 +41,5 @@ runs:
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ join(fromJSON(steps.data.outputs.tags), ', ') }}
context: images/${{ inputs.version }}/${{ inputs.context }}
cache-from: type=registry,ref=${{ fromJSON(steps.data.outputs.tags)[0] }}-cache
cache-to: type=registry,ref=${{ fromJSON(steps.data.outputs.tags)[0] }}-cache,mode=max
cache-from: type=registry,ref=${{ fromJSON(steps.data.outputs.cache) }}
cache-to: type=registry,ref=${{ fromJSON(steps.data.outputs.cache) }},mode=max
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ jobs:
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- uses: dataaxiom/ghcr-cleanup-action@main
- name: Clean emacs untagged images
uses: dataaxiom/ghcr-cleanup-action@main
with:
package: emacs
token: ${{ secrets.GITHUB_TOKEN }}
- name: Clean emacs-cache untagged images
uses: dataaxiom/ghcr-cleanup-action@main
with:
package: emacs-cache
token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions bin/images
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Image
directory: directory,
tags: tags,
tags_with_repository: tags_with_repository,
cache: cache,
depends: depends,
depends_with_repository: depends_with_repository,
children: children
Expand All @@ -124,6 +125,10 @@ class Image
end.flatten
end

def cache
tags_with_repository.first.sub('emacs:', 'emacs-cache:')
end

def depends
tags[0].split('-')[0..-2].join('-')
end
Expand Down

0 comments on commit 926ff92

Please sign in to comment.