Skip to content

Docker - NextJS GHCR registry cache by @juttayaya from main #3

Docker - NextJS GHCR registry cache by @juttayaya from main

Docker - NextJS GHCR registry cache by @juttayaya from main #3

name: Docker - NextJS GHCR registry cache
on:
workflow_dispatch:
push:
branches:
## GitHub Actions need '**' to match branches with '/' in their name
- '**'
paths:
- "nextjs-blog/**"
tags:
- '*'
pull_request:
branches:
- 'main'
permissions:
id-token: write
contents: read
packages: write
defaults:
run:
shell: bash
run-name: ${{ github.workflow }} by @${{ github.actor }} from ${{ github.ref_name }}
jobs:
build:
name: Build and Push Image
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: deptagency/nextjs-blog
steps:
-
name: Check out code
uses: actions/checkout@v3
-
name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker meta
id: dockermeta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
driver-opts: image=moby/buildkit:latest
-
name: Build Tag and Push Docker image
uses: docker/build-push-action@v4
with:
file: nextjs-blog/docker/Dockerfile
context: nextjs-blog
tags: ${{ steps.dockermeta.outputs.tags }}
labels: ${{ steps.dockermeta.outputs.labels }}
pull: true
push: true
cache-from: type=registry,ref=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:dockercache
cache-to: type=registry,ref=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:dockercache,mode=max,image-manifest=true