Merge pull request #112 from HideyoshiSolutions/develop
develop - chore: better and more secure docker cache
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
node_modules
|
node_modules/*
|
||||||
dist
|
dist/*
|
||||||
|
.k8s/*
|
||||||
|
.github/*
|
||||||
|
|
||||||
.github
|
|
||||||
.gitignore
|
.gitignore
|
||||||
|
.dockerignore
|
||||||
Dockerfile
|
Dockerfile
|
||||||
README.md
|
README.md
|
||||||
.k8s
|
|
||||||
|
|
||||||
.env
|
.env
|
||||||
.secret
|
.secret
|
||||||
31
.github/workflows/deploy.yml
vendored
31
.github/workflows/deploy.yml
vendored
@@ -57,17 +57,17 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')
|
OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')
|
||||||
REPO=$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')
|
REPO=$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
# Determine tag
|
# Determine tag
|
||||||
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
||||||
TAG="latest"
|
TAG="latest"
|
||||||
else
|
else
|
||||||
TAG="dev"
|
TAG="dev"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
|
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
|
||||||
IMAGE_BASE="ghcr.io/${OWNER}/${REPO}"
|
IMAGE_BASE="ghcr.io/${OWNER}/${REPO}"
|
||||||
|
|
||||||
echo "IMAGE_LATEST=${IMAGE_BASE}:${TAG}" >> $GITHUB_ENV
|
echo "IMAGE_LATEST=${IMAGE_BASE}:${TAG}" >> $GITHUB_ENV
|
||||||
echo "IMAGE_SHA=${IMAGE_BASE}:sha-${SHORT_SHA}" >> $GITHUB_ENV
|
echo "IMAGE_SHA=${IMAGE_BASE}:sha-${SHORT_SHA}" >> $GITHUB_ENV
|
||||||
|
|
||||||
@@ -80,8 +80,12 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
${{ env.IMAGE_LATEST }}
|
${{ env.IMAGE_LATEST }}
|
||||||
${{ env.IMAGE_SHA }}
|
${{ env.IMAGE_SHA }}
|
||||||
cache-from: type=registry,ref=${{ env.IMAGE_LATEST }}
|
cache-from: |
|
||||||
cache-to: type=inline
|
type=registry,ref=ghcr.io/hideyoshisolutions/frontend-hideyoshi.com:cache-${{ github.ref_name }}-amd64
|
||||||
|
type=registry,ref=ghcr.io/hideyoshisolutions/frontend-hideyoshi.com:cache-${{ github.ref_name }}-arm64
|
||||||
|
cache-to: |
|
||||||
|
type=registry,ref=ghcr.io/hideyoshisolutions/frontend-hideyoshi.com:cache-${{ github.ref_name }}-amd64,mode=max,platform=linux/amd64
|
||||||
|
type=registry,ref=ghcr.io/hideyoshisolutions/frontend-hideyoshi.com:cache-${{ github.ref_name }}-arm64,mode=max,platform=linux/arm64
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: [docker]
|
needs: [docker]
|
||||||
@@ -112,21 +116,24 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')
|
OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')
|
||||||
REPO=$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')
|
REPO=$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')
|
||||||
|
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
|
||||||
|
|
||||||
IMAGE_BASE="ghcr.io/${OWNER}/${REPO}"
|
IMAGE_BASE="ghcr.io/${OWNER}/${REPO}"
|
||||||
IMAGE_TAG="${{ github.event.inputs.tag || 'latest' }}"
|
IMAGE_TAG="sha-${SHORT_SHA}"
|
||||||
|
|
||||||
echo "IMAGE_BASE=${IMAGE_BASE}" >> $GITHUB_ENV
|
echo "IMAGE_BASE=${IMAGE_BASE}" >> $GITHUB_ENV
|
||||||
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
|
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Apply Kubernetes Manifests - Configuration
|
- name: Apply Kubernetes Manifests - Configuration
|
||||||
run: envsubst < .k8s/config.yml | kubectl apply -f -
|
run: cat .k8s/config.yml | envsubst | kubectl apply -f -
|
||||||
|
|
||||||
- name: Apply Kubernetes Manifests - Deployment
|
- name: Apply Kubernetes Manifests - Deployment
|
||||||
run: envsubst < .k8s/deployment.yaml | kubectl apply -f -
|
run: |
|
||||||
|
cat .k8s/deployment.yaml | envsubst | kubectl apply -f -
|
||||||
|
cat .k8s/deployment.yaml | envsubst | kubectl rollout status deployment/frontend-deployment -n ${KUBE_NAMESPACE} --timeout=120s
|
||||||
|
|
||||||
- name: Apply Kubernetes Manifests - Service
|
- name: Apply Kubernetes Manifests - Service
|
||||||
run: envsubst < .k8s/service.yaml | kubectl apply -f -
|
run: cat .k8s/service.yaml | envsubst | kubectl apply -f -
|
||||||
|
|
||||||
- name: Apply Kubernetes Manifests - Ingress
|
- name: Apply Kubernetes Manifests - Ingress
|
||||||
run: envsubst < .k8s/ingress.yaml | kubectl apply -f -
|
run: cat .k8s/ingress.yaml | envsubst | kubectl apply -f -
|
||||||
|
|||||||
Reference in New Issue
Block a user