@@ -3,9 +3,9 @@ name: deploy-appengine Integration
33on : [push, pull_request]
44
55jobs :
6- gcloud :
6+ working-directory :
77 if : ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
8- name : with setup-gcloud
8+ name : with working directory
99 runs-on : ubuntu-latest
1010 steps :
1111 - uses : actions/checkout@v2
@@ -16,12 +16,13 @@ jobs:
1616 export_default_credentials : true
1717 - name : create app
1818 run : |-
19- cat <<EOF > ${{ github.workspace }}/app.yaml
19+ mkdir app
20+ cat <<EOF > ${{ github.workspace }}/app/app.yaml
2021 service: "${{ github.job }}-${{ github.run_number }}"
2122 runtime: "nodejs10"
2223 EOF
2324
24- cat <<EOF > ${{ github.workspace }}/server.js
25+ cat <<EOF > ${{ github.workspace }}/app/ server.js
2526 const http = require('http');
2627 const server = http.createServer(function (req, res) {
2728 res.writeHead(200)
4445 uses : ./
4546 with :
4647 project_id : ${{ secrets.APPENGINE_DEPLOY_PROJECT_ID }}
47- deliverables : ${{ github.workspace }}/app.yaml
48- version : gcloud
48+ working_directory : app/
4949 promote : false
5050 - name : Test Output
5151 run : |-
@@ -58,22 +58,29 @@ jobs:
5858 --retry-delay 5 \
5959 --retry-max-time 300
6060 - name : Clean Up
61+ if : ${{ always() }}
6162 run : gcloud app services delete "${{ github.job }}-${{ github.run_number }}" --quiet
6263
63- b64-json :
64+ deliverable :
6465 if : ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
65- name : with base64 json creds
66+ name : with deliverable path
6667 runs-on : ubuntu-latest
6768 steps :
6869 - uses : actions/checkout@v2
70+ - uses : google-github-actions/setup-gcloud@master
71+ with :
72+ project_id : ${{ secrets.APPENGINE_DEPLOY_PROJECT_ID }}
73+ service_account_key : ${{ secrets.APPENGINE_DEPLOY_SA_KEY_JSON }}
74+ export_default_credentials : true
6975 - name : create app
7076 run : |-
71- cat <<EOF > ${{ github.workspace }}/app.yaml
77+ mkdir app
78+ cat <<EOF > ${{ github.workspace }}/app/app.yaml
7279 service: "${{ github.job }}-${{ github.run_number }}"
7380 runtime: "nodejs10"
7481 EOF
7582
76- cat <<EOF > ${{ github.workspace }}/server.js
83+ cat <<EOF > ${{ github.workspace }}/app/ server.js
7784 const http = require('http');
7885 const server = http.createServer(function (req, res) {
7986 res.writeHead(200)
@@ -95,10 +102,9 @@ jobs:
95102 name : Deploy to App Engine
96103 uses : ./
97104 with :
98- credentials : ${{ secrets.APPENGINE_DEPLOY_SA_KEY_B64 }}
99- deliverables : ${{ github.workspace }}/app.yaml
100- version : b64-json
101- promote : false # Allows for deletion
105+ project_id : ${{ secrets.APPENGINE_DEPLOY_PROJECT_ID }}
106+ deliverables : app/app.yaml
107+ promote : false
102108 - name : Test Output
103109 run : |-
104110 curl '${{ steps.deploy.outputs.url }}' \
@@ -110,29 +116,20 @@ jobs:
110116 --retry-delay 5 \
111117 --retry-max-time 300
112118 - name : Clean Up
119+ if : ${{ always() }}
113120 run : gcloud app services delete "${{ github.job }}-${{ github.run_number }}" --quiet
114-
115- json :
121+
122+ failure :
116123 if : ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
117- name : with json creds
124+ name : with bad path
118125 runs-on : ubuntu-latest
119126 steps :
120127 - uses : actions/checkout@v2
121- - name : create app
122- run : |-
123- cat <<EOF > ${{ github.workspace }}/app.yaml
124- service: "${{ github.job }}-${{ github.run_number }}"
125- runtime: "nodejs10"
126- EOF
127-
128- cat <<EOF > ${{ github.workspace }}/server.js
129- const http = require('http');
130- const server = http.createServer(function (req, res) {
131- res.writeHead(200)
132- res.end('Hello world!');
133- });
134- server.listen(process.env.PORT || 8080);
135- EOF
128+ - uses : google-github-actions/setup-gcloud@master
129+ with :
130+ project_id : ${{ secrets.APPENGINE_DEPLOY_PROJECT_ID }}
131+ service_account_key : ${{ secrets.APPENGINE_DEPLOY_SA_KEY_JSON }}
132+ export_default_credentials : true
136133 - name : Build dependency
137134 working-directory : setupGcloudSDK
138135 run : |-
@@ -143,23 +140,28 @@ jobs:
143140 run : |-
144141 npm install
145142 npm run build
146- - id : deploy
147- name : Deploy to App Engine
143+ - id : cwd
148144 uses : ./
145+ continue-on-error : true
149146 with :
150- credentials : ${{ secrets.APPENGINE_DEPLOY_SA_KEY_JSON }}
151- deliverables : ${{ github.workspace }}/app.yaml
152- version : json
153- promote : false # Allows for deletion
154- - name : Test Output
147+ project_id : ${{ secrets.APPENGINE_DEPLOY_PROJECT_ID }}
148+ working_directory : this/path/doesnt/exist/
149+ promote : false
150+ - name : Catch failure
155151 run : |-
156- curl '${{ steps.deploy.outputs.url }}' \
157- --silent \
158- --fail \
159- --location \
160- --retry 5 \
161- --retry-connrefused \
162- --retry-delay 5 \
163- --retry-max-time 300
164- - name : Clean Up
165- run : gcloud app services delete "${{ github.job }}-${{ github.run_number }}" --quiet
152+ if [ ${{ steps.cwd.outcome }} != 'failure' ]; then
153+ exit 1
154+ fi
155+ - id : deliverable
156+ uses : ./
157+ continue-on-error : true
158+ with :
159+ project_id : ${{ secrets.APPENGINE_DEPLOY_PROJECT_ID }}
160+ deliverables : this/path/doesnt/exist/app.yaml
161+ promote : false
162+ - name : Catch failure
163+ run : |-
164+ if [ ${{ steps.deliverable.outcome }} != 'failure' ]; then
165+ exit 1
166+ fi
167+
0 commit comments