This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
chore: change interval to 30 seconds rather than every second #244
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: Deploy to Staging environment. | |
on: | |
pull_request: | |
branches: | |
- master | |
env: | |
REGION: "us-central1" | |
BACKEND_IMAGE: "us-central1-docker.pkg.dev/pagoda-data-stack-dev/cloud-run-source-deploy/explorer-backend" | |
FRONTEND_IMAGE: "us-central1-docker.pkg.dev/pagoda-data-stack-dev/cloud-run-source-deploy/explorer-frontend" | |
PR_NUMBER: ${{ github.event.number }} | |
jobs: | |
build-frontend: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
name: "Checkout near-explorer" | |
- name: Login to Artifact Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGION }}-docker.pkg.dev | |
username: _json_key | |
password: ${{ secrets.CI_EXPLORER_UI_SA_DEV_KEY }} | |
- name: Build Docker image and push to Google Artifact Registry | |
id: docker-push-tagged | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
file: ./frontend/Dockerfile | |
tags: "${{ env.FRONTEND_IMAGE }}:${{ env.PR_NUMBER }},${{ env.FRONTEND_IMAGE }}:${{ github.run_attempt }}-${{ github.sha }}" | |
deploy-frontend: | |
runs-on: ubuntu-latest | |
needs: build-frontend | |
environment: | |
name: dev-frontend | |
url: ${{ steps.gcp_url.outputs.deploy_url }} | |
steps: | |
- uses: actions/checkout@v3 | |
name: "Checkout near-explorer" | |
- name: "Authenticate to GCloud" | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: "${{ secrets.CI_EXPLORER_UI_SA_DEV_KEY }}" | |
- name: "Get Backend services URLs" | |
id: "gcp_services_urls" | |
run: | | |
backend_testnet_url=$(gcloud run services describe "explorer-backend-testnet" --platform managed --region "${{ env.REGION }}" --project "pagoda-data-stack-dev"\ | |
--format 'value(status.url)') | |
backend_mainnet_url=$(gcloud run services describe "explorer-backend-mainnet" --platform managed --region "${{ env.REGION }}" --project "pagoda-data-stack-dev"\ | |
--format 'value(status.url)') | |
prefix="https://" | |
backend_testnet_url="${backend_testnet_url#"$prefix"}" | |
backend_mainnet_url="${backend_mainnet_url#"$prefix"}" | |
echo "BACKEND_TESTNET_URL=${backend_testnet_url}" >> $GITHUB_ENV | |
echo "BACKEND_MAINNET_URL=${backend_mainnet_url}" >> $GITHUB_ENV | |
- name: "Deploy the Frontend" | |
run: | | |
gcloud run deploy explorer-frontend --image="${{ env.FRONTEND_IMAGE }}:${{ env.PR_NUMBER }}" --region=${{ env.REGION }}\ | |
--tag="pr-${{ env.PR_NUMBER }}"\ | |
--update-env-vars "NEAR_EXPLORER_CONFIG__BACKEND__HOSTS__TESTNET=pr-${{ env.PR_NUMBER }}---${{ env.BACKEND_TESTNET_URL }}"\ | |
--update-env-vars "NEAR_EXPLORER_CONFIG__BACKEND__HOSTS__MAINNET=pr-${{ env.PR_NUMBER }}---${{ env.BACKEND_MAINNET_URL }}"\ | |
--update-env-vars "NEAR_EXPLORER_CONFIG__BACKEND_SSR__HOSTS__TESTNET=pr-${{ env.PR_NUMBER }}---${{ env.BACKEND_TESTNET_URL }}"\ | |
--update-env-vars "NEAR_EXPLORER_CONFIG__BACKEND_SSR__HOSTS__MAINNET=pr-${{ env.PR_NUMBER }}---${{ env.BACKEND_MAINNET_URL }}"\ | |
--update-env-vars "BRANCH=$GITHUB_REF_NAME"\ | |
--update-env-vars "COMMIT_SHA=${{ github.event.pull_request.head.sha }}"\ | |
--update-env-vars "GCP=true"\ | |
- name: "Get deployment URL" | |
id: "gcp_url" | |
run: | | |
url=$(gcloud run services describe "explorer-frontend" --platform managed --region "${{ env.REGION }}" --project "pagoda-data-stack-dev"\ | |
--format 'value(status.url)') | |
match="https://" | |
tagged_url="https://${url%%${match}*}pr-${{ env.PR_NUMBER }}---${url##*${match}}" | |
echo deploy_url=$tagged_url >> $GITHUB_OUTPUT | |
build-backend: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
name: "Checkout backend-repo" | |
- name: Login to Artifact Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGION }}-docker.pkg.dev | |
username: _json_key | |
password: ${{ secrets.CI_EXPLORER_UI_SA_DEV_KEY }} | |
- name: Build Docker image and push to Google Artifact Registry | |
id: docker-push-tagged | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
file: ./backend/Dockerfile | |
tags: "${{ env.BACKEND_IMAGE }}:${{ env.PR_NUMBER }},${{ env.BACKEND_IMAGE }}:${{ github.run_attempt }}-${{ github.sha }}" | |
deploy-backend-testnet: | |
environment: | |
name: dev-backend-testnet | |
url: ${{ steps.gcp_url.outputs.deploy_url }} | |
runs-on: ubuntu-latest | |
needs: build-backend | |
steps: | |
- uses: actions/checkout@v3 | |
name: "Checkout backend-repo" | |
- name: "Authenticate to GCloud" | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: "${{ secrets.CI_EXPLORER_UI_SA_DEV_KEY }}" | |
- name: "Deploy Backend Testnet" | |
run: | | |
gcloud run deploy explorer-backend-testnet --image="${{ env.BACKEND_IMAGE }}:${{ env.PR_NUMBER }}" --region=${{ env.REGION }}\ | |
--tag="pr-${{ env.PR_NUMBER }}"\ | |
--update-env-vars "BRANCH=$GITHUB_REF_NAME"\ | |
--update-env-vars "COMMIT_SHA=${{ github.event.pull_request.head.sha }}"\ | |
- name: "Get deployment URL" | |
id: "gcp_url" | |
run: | | |
url=$(gcloud run services describe "explorer-backend-testnet" --platform managed --region "${{ env.REGION }}" --project "pagoda-data-stack-dev"\ | |
--format 'value(status.url)') | |
match="https://" | |
tagged_url="https://${url%%${match}*}pr-${{ env.PR_NUMBER }}---${url##*${match}}" | |
echo deploy_url=$tagged_url >> $GITHUB_OUTPUT | |
deploy-backend-mainnet: | |
environment: | |
name: dev-backend-mainnet | |
url: ${{ steps.gcp_url.outputs.deploy_url }} | |
runs-on: ubuntu-latest | |
needs: build-backend | |
steps: | |
- uses: actions/checkout@v3 | |
name: "Checkout backend-repo" | |
- name: "Authenticate to GCloud" | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: "${{ secrets.CI_EXPLORER_UI_SA_DEV_KEY }}" | |
- name: "Deploy Backend Mainnet" | |
run: | | |
gcloud run deploy explorer-backend-mainnet --image="${{ env.BACKEND_IMAGE }}:${{ env.PR_NUMBER }}" --region=${{ env.REGION }}\ | |
--tag="pr-${{ env.PR_NUMBER }}"\ | |
--update-env-vars "BRANCH=$GITHUB_REF_NAME"\ | |
--update-env-vars "COMMIT_SHA=${{ github.event.pull_request.head.sha }}"\ | |
- name: "Get deployment URL" | |
id: "gcp_url" | |
run: | | |
url=$(gcloud run services describe "explorer-backend-mainnet" --platform managed --region "${{ env.REGION }}" --project "pagoda-data-stack-dev"\ | |
--format 'value(status.url)') | |
match="https://" | |
tagged_url="https://${url%%${match}*}pr-${{ env.PR_NUMBER }}---${url##*${match}}" | |
echo deploy_url=$tagged_url >> $GITHUB_OUTPUT |