13
13
build-push-artifact :
14
14
runs-on : ubuntu-latest
15
15
outputs :
16
- build_status : ${{ steps.set_output .outputs.build_status }}
16
+ should_deploy : ${{ steps.deploy .outputs.BUILD_STEP_RAN }}
17
17
steps :
18
18
- name : " Checkout"
19
19
uses : " actions/checkout@v3"
33
33
- 'matching_service/**'
34
34
collab_service:
35
35
- 'collab_service/**'
36
+ code_execution:
37
+ - 'code_execution/**'
38
+
36
39
37
40
- name : ' Create env file'
38
41
run : |
@@ -54,41 +57,82 @@ jobs:
54
57
run : |-
55
58
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
56
59
57
- - name : Determine Build Status
58
- id : set_output
59
- run : echo "::set-output name=build_status::false"
60
-
61
60
- name : 1. Build and Push frontend
61
+ id : a
62
62
if : steps.changes.outputs.frontend == 'true'
63
63
run : |
64
64
docker-compose build frontend
65
65
docker-compose push frontend
66
- echo "::set-output name=build_status::true"
67
66
68
67
- name : 2. Build and Push question-service
68
+ id : b
69
69
if : steps.changes.outputs.question_service == 'true'
70
70
run : |
71
71
docker-compose build question-service
72
72
docker-compose push question-service
73
- echo "::set-output name=build_status::true"
74
73
75
74
- name : 3. Build and Push user-service
75
+ id : c
76
76
if : steps.changes.outputs.user_service == 'true'
77
77
run : |
78
78
docker-compose build user-service
79
79
docker-compose push user-service
80
- echo "::set-output name=build_status::true"
81
80
82
81
- name : 4. Build and Push matching-service
82
+ id : d
83
83
if : steps.changes.outputs.matching_service == 'true'
84
84
run : |
85
85
docker-compose build matching-service
86
86
docker-compose push matching-service
87
- echo "::set-output name=build_status::true"
88
87
89
88
- name : 5. Build and Push collab-service
89
+ id : e
90
90
if : steps.changes.outputs.collab_service == 'true'
91
91
run : |
92
92
docker-compose build collab-service
93
93
docker-compose push collab-service
94
- echo "::set-output name=build_status::true"
94
+
95
+ - name : 6. Build and Push code-execution
96
+ id : f
97
+ if : steps.changes.outputs.code_execution == 'true'
98
+ run : |
99
+ docker-compose build code-execution
100
+ docker-compose push code-execution
101
+
102
+ - name : determine deploy step
103
+ id : deploy
104
+ if : ${{ steps.a.conclusion == 'success' || steps.b.conclusion == 'success' || steps.c.conclusion == 'success' || steps.d.conclusion == 'success' || steps.e.conclusion == 'success' || steps.f.conclusion == 'success' }}
105
+ run : |
106
+ echo "BUILD_STEP_RAN=true" >> $GITHUB_OUTPUT
107
+
108
+
109
+ deploy :
110
+ needs : build-push-artifact
111
+ if : ${{needs.build-push-artifact.outputs.should_deploy== 'true'}}
112
+ runs-on : ubuntu-latest
113
+ steps :
114
+ - name : Checkout code
115
+ uses : actions/checkout@v2
116
+
117
+ - name : " Set up google auth"
118
+ id : auth
119
+ uses : " google-github-actions/auth@v1"
120
+ with :
121
+ credentials_json : " ${{ secrets.SERVICE_ACCOUNT_KEY }}"
122
+
123
+ - name : " Use gcloud CLI"
124
+ run : " gcloud info"
125
+
126
+ - name : " SSH to VM"
127
+ id : ' compute-ssh'
128
+ uses : ' google-github-actions/ssh-compute@v0'
129
+ with :
130
+ instance_name : ' peerprep-prod'
131
+ zone : ' asia-southeast1-b'
132
+ ssh_private_key : ' ${{ secrets.SSH_KEY }}'
133
+ command : ' echo "${{ secrets.ENV_FILE }}" | sudo tee /usr/src/peerprep/.env > /dev/null && sudo chmod 777 /usr/src/peerprep/scripts/init.sh && sudo /usr/src/peerprep/scripts/init.sh'
134
+
135
+ - id : ' test'
136
+ run : |-
137
+ echo '${{ steps.compute-ssh.outputs.stdout }}'
138
+ echo '${{ steps.compute-ssh.outputs.stderr }}'
0 commit comments