Skip to content

Commit

Permalink
CI: cache docker
Browse files Browse the repository at this point in the history
  • Loading branch information
anishshobithps committed Jan 11, 2025
1 parent 0d99b66 commit 5b682e7
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,47 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
- name: Check for Docker changes
id: docker-changes
run: |
CHANGED=0
git fetch origin main
if git diff --name-only HEAD^ HEAD | grep -q "^\.docker/"; then
CHANGED=1
fi
echo "changed=${CHANGED}" >> $GITHUB_OUTPUT
- name: Set up Docker
if: steps.docker-changes.outputs.changed == '1'
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: steps.docker-changes.outputs.changed == '1'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and cache Docker image
if: steps.docker-changes.outputs.changed == '1'
uses: docker/build-push-action@v5
with:
context: .docker
push: true
tags: ghcr.io/${{ github.repository }}/latex-builder:latest
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:buildcache,mode=max
tags: ghcr.io/${{ github.repository }}/resume:latest
cache-from: |
type=registry,ref=ghcr.io/${{ github.repository }}/resume:buildcache
type=registry,ref=ghcr.io/${{ github.repository }}/resume:latest
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/resume:buildcache,mode=max

- name: Pull latest Docker image
run: docker pull ghcr.io/${{ github.repository }}/resume:latest

- name: Build LaTeX document
run: |
docker run --rm -v ${{ github.workspace }}:/latex \
ghcr.io/${{ github.repository }}/latex-builder:latest \
ghcr.io/${{ github.repository }}/resume:latest \
main.tex "Anish_Shobith_P_S_Resume.pdf"
- name: Get current date
Expand Down

0 comments on commit 5b682e7

Please sign in to comment.