-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (47 loc) · 1.77 KB
/
prod-2.yml
File metadata and controls
59 lines (47 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Deploy New Production
on:
workflow_dispatch: # This allows the workflow to be manually triggered from the GitHub UI
push:
branches:
- main
env:
PROJECT_NUMBER: "641188643433"
SERVICE_ACCOUNT_EMAIL: "github-actions@agora-near-25q4-prd.iam.gserviceaccount.com"
PROJECT_ID: "agora-near-25q4-prd"
REGION: "us-west1"
DOCKER_IMAGE: "us-west1-docker.pkg.dev/agora-near-25q4-prd/indexer/near-sink-service"
jobs:
deploy-prod:
runs-on: ubuntu-latest
environment:
name: production
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Authenticate to Google Cloud using OIDC
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/${{env.PROJECT_NUMBER}}/locations/global/workloadIdentityPools/github-identity-pool/providers/github
service_account: ${{env.SERVICE_ACCOUNT_EMAIL}}
- name: Configure gcloud
run: gcloud config set project ${{env.PROJECT_ID}}
- name: Login to Artifact Registry
run: gcloud auth configure-docker ${{env.REGION}}-docker.pkg.dev
- name: Build Docker image
run: docker build -t ${{env.DOCKER_IMAGE}} .
- name: Push Docker image to Artifact Registry
run: docker push ${{env.DOCKER_IMAGE}}
- name: Docker cleanup on VM
run: |
gcloud compute ssh indexer-vm \
--zone=${{env.REGION}}-a \
--project=${{env.PROJECT_ID}} \
--command="sudo docker system prune --all --force --volumes"
- name: Restart Compute Engine VM
run: |
gcloud compute instances reset indexer-vm \
--zone=${{env.REGION}}-a \
--project=${{env.PROJECT_ID}}