diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 03c9ac4..9ac8cfa 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -14,6 +14,8 @@ jobs: tag: ${{ steps.export.outputs.tag }} runs-on: ubuntu-latest + env: + image: cranecloud/monitoring-api steps: - name: Checkout @@ -24,19 +26,11 @@ 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 @@ -44,13 +38,13 @@ jobs: 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 @@ -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) @@ -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: | diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 6b03f24..e3a3372 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -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: | diff --git a/helm/values.prod.yaml b/helm/values.prod.yaml index ae1ce42..67a62c7 100644 --- a/helm/values.prod.yaml +++ b/helm/values.prod.yaml @@ -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 }}