Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cached deployment of Docker using github actions #2746

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Deploy Care


on:
workflow_dispatch:
push:
Expand Down Expand Up @@ -63,6 +64,9 @@ jobs:

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
kshitijk4poor marked this conversation as resolved.
Show resolved Hide resolved

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -71,19 +75,6 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-build-${{ hashFiles('Pipfile.lock', 'docker/prod.Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-build-

- name: Create new cache
run: |
mkdir -p /tmp/.buildx-cache
mkdir -p /tmp/.buildx-cache-new

- name: Build and push image
uses: docker/build-push-action@v6
with:
Expand All @@ -96,8 +87,10 @@ jobs:
build-args: |
APP_VERSION=${{ github.sha }}
ADDITIONAL_PLUGS=${{ env.ADDITIONAL_PLUGS }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
cache-from: |
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
type=registry,ref=ghcr.io/${{ github.repository }}:latest
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max

- name: Create Sentry release
uses: getsentry/action-release@v1
Expand All @@ -107,13 +100,6 @@ jobs:
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
version: ${{ github.sha }}
- name: Update cache
if: always() # Run even if previous steps fail
run: |
if [ -d "/tmp/.buildx-cache-new" ]; then
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
fi

notify-release:
needs: build
Expand Down