Skip to content
Open
Show file tree
Hide file tree
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
80 changes: 45 additions & 35 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
tag: ${{ steps.export.outputs.tag }}

runs-on: ubuntu-latest
env:
image: cranecloud/monitoring-api

steps:
- name: Checkout
Expand All @@ -24,33 +26,25 @@ jobs:
- name: Install (Buildx)
uses: docker/setup-buildx-action@v3

- name: Login (GCP)
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.CREDENTIALS_JSON }}

- name: Install (Gcloud)
uses: google-github-actions/setup-gcloud@v1
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
project_id: crane-cloud-274413
install_components: "gke-gcloud-auth-plugin"

- name: Login (GCR)
run: gcloud auth configure-docker
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- id: meta
name: Tag
uses: docker/metadata-action@v3
with:
flavor: |
latest=true
images: gcr.io/crane-cloud-274413/monitoring-api
images: ${{ env.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' }}
type=sha,prefix=prod-

- name: Build
uses: docker/build-push-action@v2
Expand All @@ -69,9 +63,19 @@ jobs:
with:
script: |
const metadata = JSON.parse(`${{ steps.meta.outputs.json }}`)
const fullUrl = metadata.tags.find((t) => t.includes(':sha-'))
const isRelease = context.eventName === 'release'

let fullUrl
if (isRelease) {
// Pick the full semver tag e.g. 1.16.0
fullUrl = metadata.tags.find((t) => /:\d+\.\d+\.\d+$/.test(t))
} else {
// Pick the sha tag e.g. prod-abc1234
fullUrl = metadata.tags.find((t) => t.includes(':prod-'))
}

if (fullUrl == null) {
core.error('Unable to find sha tag of image')
core.error('Unable to find tag of image')
} else {
const tag = fullUrl.split(':')[1]
core.setOutput('image', fullUrl)
Expand All @@ -90,26 +94,32 @@ jobs:
namespace: cranecloud-prod

steps:
- name: Clone
# --- RENU DEPLOYEMENT ---
- name: Checkout code
uses: actions/checkout@v2

- name: Login (GCP)
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.CREDENTIALS_JSON }}

- name: Install (Gcloud)
uses: google-github-actions/setup-gcloud@v1
with:
project_id: crane-cloud-274413
install_components: "gke-gcloud-auth-plugin"

- name: Login (Kubernetes Cluster)
uses: google-github-actions/get-gke-credentials@v1
- uses: azure/k8s-set-context@v1
with:
cluster_name: staging-cluster
location: us-central1-a
project_id: crane-cloud-274413
kubeconfig: ${{ secrets.RENU_KUBECONFIG}}

# --- GCP DEPLOYEMENT ---
# - name: Login (GCP)
# uses: google-github-actions/auth@v2
# with:
# credentials_json: ${{ secrets.CREDENTIALS_JSON }}

# - name: Install (Gcloud)
# uses: google-github-actions/setup-gcloud@v1
# with:
# project_id: crane-cloud-274413
# install_components: "gke-gcloud-auth-plugin"

# - name: Login (Kubernetes Cluster)
# uses: google-github-actions/get-gke-credentials@v1
# with:
# cluster_name: staging-cluster
# location: us-central1-a
# project_id: crane-cloud-274413

- name: Add Repo (cranecloud)
run: |
Expand Down
38 changes: 20 additions & 18 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,32 @@ jobs:
image: cranecloud/monitoring-api

steps:
# --- RENU DEPLOYEMENT ---
- name: Checkout code
uses: actions/checkout@v2

# - uses: azure/k8s-set-context@v1
# with:
# kubeconfig: ${{ secrets.RENU_KUBECONFIG}}

- name: Login (GCP)
uses: google-github-actions/auth@v0
- uses: azure/k8s-set-context@v1
with:
credentials_json: ${{ secrets.CREDENTIALS_JSON }}
kubeconfig: ${{ secrets.RENU_KUBECONFIG}}

- name: Install (Gcloud)
uses: google-github-actions/setup-gcloud@v1
with:
project_id: crane-cloud-274413
install_components: "gke-gcloud-auth-plugin"
# --- GCP DEPLOYEMENT ---
# - name: Login (GCP)
# uses: google-github-actions/auth@v0
# with:
# credentials_json: ${{ secrets.CREDENTIALS_JSON }}

- name: Login (Kubernetes Cluster)
uses: google-github-actions/get-gke-credentials@v1
with:
cluster_name: staging-cluster
location: us-central1-a
project_id: crane-cloud-274413
# - name: Install (Gcloud)
# uses: google-github-actions/setup-gcloud@v1
# with:
# project_id: crane-cloud-274413
# install_components: "gke-gcloud-auth-plugin"

# - name: Login (Kubernetes Cluster)
# uses: google-github-actions/get-gke-credentials@v1
# with:
# cluster_name: staging-cluster
# location: us-central1-a
# project_id: crane-cloud-274413

- name: Add Repo (cranecloud)
run: |
Expand Down
2 changes: 1 addition & 1 deletion helm/values.prod.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
replicaCount: 1

image:
repository: gcr.io/crane-cloud-274413/monitoring-api
repository: cranecloud/monitoring-api
pullPolicy: Always
tag: ${{ DOCKER_IMAGE_TAG }}

Expand Down