Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

GCP registry (#15)

GCP registry (#15) #15

# This is a basic workflow to help you get started with Actions
name: Build Big Dipper UI (Staging)
# Controls when the workflow will run
on:
push:
branches:
- lava
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
id-token: write
contents: read
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
main:
environment: Configure CI/CD
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/184173984234/locations/global/workloadIdentityPools/oidc-github-identity-pool/providers/oidc-github-provider'
service_account: 'oidc-github-access@lavanet-staging.iam.gserviceaccount.com'
- name: 'Set up GCP CLI'
uses: 'google-github-actions/setup-gcloud@v1'
- name: 'GCP CLI Info'
run: |
gcloud info
gcloud auth list --filter=status:ACTIVE --format="value(account)"
- name: 'GCP set project'
run: |
gcloud config set project lavanet-staging
- name: 'Authenticate to Google Artifact'
run: |
gcloud auth configure-docker us-central1-docker.pkg.dev,europe-west4-docker.pkg.dev
- name: Set up NOW environment variable
id: "env-now"
run: |
echo "NOW=$(date +'%Y%m%dT%H%M%S')" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: "us-central1-docker.pkg.dev/lavanet-staging/growth-staging-us-central1/bd-ui-staging"
IMAGE_TAG: ${{ github.sha }}
NOW: ${{ env.NOW }}
run: |
docker buildx build \
-t $REGISTRY:$IMAGE_TAG \
-t $REGISTRY:latest \
-t $REGISTRY:$IMAGE_TAG-$NOW \
--build-arg NEXT_PUBLIC_GRAPHQL_URL=https://bd-graphql.${{ secrets.STAGING_DOMAIN }}/v1/graphql \
--build-arg NEXT_PUBLIC_GRAPHQL_WS=wss://bd-graphql.${{ secrets.STAGING_DOMAIN }}/v1/graphql \
--build-arg NODE_ENV=production \
--build-arg PORT=3000 \
--build-arg NEXT_PUBLIC_WS_CHAIN_URL=wss://public-rpc.${{ secrets.STAGING_DOMAIN }}/rpc/websocket \
--build-arg NEXT_PUBLIC_CHAIN_TYPE=testnet \
--build-arg NEXT_PUBLIC_BLOCK_TOSTER_INTERVAL_INS=300 \
--build-arg NEXT_PUBLIC_LAVA_FAVICON_URL=https://lava-fe-assets.s3.amazonaws.com/lava-favicon.ico \
--build-arg NEXT_PUBLIC_LAVA_LOGO_URL=https://lava-fe-assets.s3.amazonaws.com/lava-icon.svg \
--build-arg NEXT_PUBLIC_LAVA_BLACK_LOGO_URL=https://lava-fe-assets.s3.amazonaws.com/lava-logo-black.svg \
--build-arg NEXT_PUBLIC_LAVA_WHITE_LOGO_URL=https://lava-fe-assets.s3.amazonaws.com/lava-logo-with-text-white.svg \
--build-arg NEXT_PUBLIC_GOOGLE_ANALYTICS=G-CEXCQSV6TZ \
--platform linux/amd64 \
--cache-from="type=local,src=/tmp/.buildx-cache" \
--cache-to="type=local,dest=/tmp/.buildx-cache-new" \
-f Dockerfile \
--push \
.
# Necessary if you don't want your cache to grow forever, until
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache || true
mv /tmp/.buildx-cache-new /tmp/.buildx-cache || true