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
78 changes: 44 additions & 34 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/database-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/database-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 @@ -93,23 +97,29 @@ jobs:
- name: Clone
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
# --- GCP DEPLOYMENT ---
# - 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

# --- RENU DEPLOYEMENT ---
- uses: azure/k8s-set-context@v1
with:
cluster_name: staging-cluster
location: us-central1-a
project_id: crane-cloud-274413
kubeconfig: ${{ secrets.RENU_KUBECONFIG}}

- name: Add Repo (cranecloud)
run: |
Expand Down
38 changes: 22 additions & 16 deletions .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

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

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

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

# --- RENU DEPLOYEMENT ---
- uses: azure/k8s-set-context@v1
with:
credentials_json: ${{ secrets.CREDENTIALS_JSON }}

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

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

- 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/database-api
repository: cranecloud/database-api
pullPolicy: Always
tag: ${{ DOCKER_IMAGE_TAG }}

Expand Down