forked from the-standard/decentralised-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df28a68
commit 09b3370
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
PROJECT_NAME: ${{ secrets.GKE_PROJECT }} | ||
CLUSTER_NAME: cluster-1 | ||
CLOUDSDK_COMPUTE_ZONE: europe-west2-c | ||
DEPLOYMENT: fork-demo | ||
NAMESPACE: default | ||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
deploy: | ||
name: Setup, Build, Publish, and Deploy | ||
runs-on: ubuntu-latest | ||
environment: production | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# Setup gcloud CLI | ||
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 | ||
with: | ||
service_account_key: ${{ secrets.GKE_SA_KEY }} | ||
project_id: ${{ secrets.GKE_PROJECT }} | ||
|
||
- run: |- | ||
gcloud --quiet auth configure-docker | ||
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e | ||
with: | ||
cluster_name: ${{ env.CLUSTER_NAME }} | ||
location: ${{ env.CLOUDSDK_COMPUTE_ZONE }} | ||
credentials: ${{ secrets.GKE_SA_KEY}} | ||
|
||
# Build the Docker image | ||
# | ||
- name: Build | ||
run: |- | ||
docker build --build-arg opensea_key=${{ vars.VITE_OPENSEA_API_KEY }} --build-arg alchemy_key=${{ vars.VITE_ALCHEMY_API_KEY }} --build-arg alchemy_sepolia_key=${{ vars.VITE_ALCHEMY_SEPOLIA_API_KEY }} --build-arg walletconnect_id=${{ vars.VITE_WALLETCONNECT_ID }} -t "gcr.io/$PROJECT_NAME/$DEPLOYMENT:${GITHUB_REF##*/}.$GITHUB_SHA" . | ||
# Push the Docker image to Google Container Registry | ||
- name: Publish | ||
run: |- | ||
docker push "gcr.io/$PROJECT_NAME/$DEPLOYMENT:${GITHUB_REF##*/}.$GITHUB_SHA" | ||
- name: Deploy | ||
run: |- | ||
export IMAGE_TAG="gcr.io/${PROJECT_NAME}/$DEPLOYMENT:${GITHUB_REF##*/}.${GITHUB_SHA}" | ||
gcloud components install gke-gcloud-auth-plugin | ||
gcloud container clusters get-credentials cluster-1 --zone $CLOUDSDK_COMPUTE_ZONE --project $PROJECT_NAME | ||
kubectl set image deployment/$DEPLOYMENT-deployment-${GITHUB_REF##*/} $DEPLOYMENT-${GITHUB_REF##*/}=${IMAGE_TAG} -n ${NAMESPACE} | ||
- name: Cleanup | ||
run: |- | ||
dont_run=true | ||
for digest in $(gcloud container images list-tags gcr.io/$PROJECT_NAME/$DEPLOYMENT --format="get(digest)" --limit=100 --filter="tags:${GITHUB_REF##*/}.* AND NOT tags:${GITHUB_REF##*/}.${GITHUB_SHA}") | ||
do | ||
if [ $dont_run != true ] | ||
then | ||
gcloud container images delete "gcr.io/$PROJECT_NAME/$DEPLOYMENT@$digest" --force-delete-tags --quiet | ||
fi | ||
dont_run=false | ||
done |