1.1.0 release #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- master | |
env: | |
PROJECT_ID: ${{ secrets.GKE_PROJECT }} | |
GKE_CLUSTER: kipr | |
GKE_ZONE: us-central1-a | |
IMAGE: kipr/simulator | |
concurrency: ${{ github.workflow }} | |
jobs: | |
build-publish: | |
name: Build | |
runs-on: ubuntu-latest | |
outputs: | |
image_version: ${{ steps.image_tag.outputs.IMAGE_TAG }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
# Calculate image tag name from commit hash | |
- name: Set image tag output | |
id: image_tag | |
run: |- | |
echo "::set-output name=IMAGE_TAG::${GITHUB_SHA::8}" | |
# Setup gcloud CLI | |
- name: Set up gcloud CLI | |
uses: google-github-actions/[email protected] | |
with: | |
service_account_key: ${{ secrets.GCR_SA_KEY }} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
# Ensure there isn't already a Docker image for this version | |
- name: Ensure Docker image does not exist | |
run: |- | |
NUM_IMAGES=$(gcloud container images list-tags gcr.io/kipr-321905/kipr/simulator --filter="tags:${{ steps.image_tag.outputs.IMAGE_TAG }}" --format=json | jq '. | length') | |
if (( NUM_IMAGES > 0 )); then exit 1; fi | |
# Configure Docker to use the gcloud command-line tool as a credential helper for authentication | |
- name: Configure Docker with gcloud | |
run: |- | |
gcloud --quiet auth configure-docker | |
# Build the Docker image | |
- name: Build Docker image | |
run: |- | |
docker build \ | |
--tag "gcr.io/$PROJECT_ID/$IMAGE:${{ steps.image_tag.outputs.IMAGE_TAG }}" \ | |
. | |
# Push the Docker image to Google Container Registry | |
- name: Publish Docker image to GCR | |
run: |- | |
docker push "gcr.io/$PROJECT_ID/$IMAGE:${{ steps.image_tag.outputs.IMAGE_TAG }}" | |
deploy-to-staging: | |
name: Deploy to staging | |
runs-on: ubuntu-latest | |
needs: build-publish | |
steps: | |
- name: Checkout deployment repo | |
uses: actions/checkout@v2 | |
with: | |
repository: 'kipr/kipr-yamls' | |
ssh-key: ${{ secrets.KIPR_YAMLS_REPO_KEY }} | |
# Get the GKE credentials so we can deploy to the cluster | |
- name: Get GKE credentials | |
uses: google-github-actions/[email protected] | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER }} | |
location: ${{ env.GKE_ZONE }} | |
credentials: ${{ secrets.GCR_SA_KEY }} | |
- name: Deploy to GKE | |
run: |- | |
helm upgrade \ | |
--install \ | |
--namespace prerelease \ | |
--values ./simulator/values.prerelease.yaml \ | |
--set imageVersion=${{ needs.build-publish.outputs.image_version }} \ | |
simulator-prerelease ./simulator |