mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-27 09:25:49 +00:00
Create release.yaml
This commit is contained in:
parent
20c33b223b
commit
f5b5169129
1 changed files with 64 additions and 0 deletions
64
.github/workflows/release.yaml
vendored
Normal file
64
.github/workflows/release.yaml
vendored
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
name: Build and Deploy to GKE
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
env:
|
||||||
|
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
|
||||||
|
DEPLOYMENT_NAME: gke-test # Add your deployment name here.
|
||||||
|
IMAGE: static-site
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
setup-build-publish-deploy:
|
||||||
|
name: Setup, Build, Publish, and Deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Setup gcloud CLI
|
||||||
|
- uses: google-github-actions/setup-gcloud@v0.2.0
|
||||||
|
with:
|
||||||
|
service_account_key: ${{ secrets.GKE_SA_KEY }}
|
||||||
|
project_id: ${{ secrets.GKE_PROJECT }}
|
||||||
|
|
||||||
|
# Configure docker to use the gcloud command-line tool as a credential helper
|
||||||
|
- run: |-
|
||||||
|
gcloud --quiet auth configure-docker
|
||||||
|
|
||||||
|
# Get the GKE credentials so we can deploy to the cluster
|
||||||
|
- uses: google-github-actions/get-gke-credentials@v0.2.1
|
||||||
|
with:
|
||||||
|
cluster_name: ${{ secrets.GKE_CLUSTER }}
|
||||||
|
location: ${{ secrets.GKE_ZONE }}
|
||||||
|
credentials: ${{ secrets.GKE_SA_KEY }}
|
||||||
|
|
||||||
|
# Build the Docker image
|
||||||
|
- name: Build
|
||||||
|
run: |-
|
||||||
|
docker build \
|
||||||
|
--tag "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" \
|
||||||
|
--build-arg GITHUB_SHA="$GITHUB_SHA" \
|
||||||
|
--build-arg GITHUB_REF="$GITHUB_REF" \
|
||||||
|
.
|
||||||
|
|
||||||
|
# Push the Docker image to Google Container Registry
|
||||||
|
- name: Publish
|
||||||
|
run: |-
|
||||||
|
docker push "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA"
|
||||||
|
|
||||||
|
# Set up kustomize
|
||||||
|
- name: Set up Kustomize
|
||||||
|
run: |-
|
||||||
|
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
|
||||||
|
chmod u+x ./kustomize
|
||||||
|
|
||||||
|
# Deploy the Docker image to the GKE cluster
|
||||||
|
- name: Deploy
|
||||||
|
run: |-
|
||||||
|
./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA
|
||||||
|
./kustomize build . | kubectl apply -f -
|
||||||
|
kubectl rollout status deployment/$DEPLOYMENT_NAME
|
||||||
|
kubectl get services -o wide
|
Loading…
Reference in a new issue