Skip to content

Commit eac5a2e

Browse files
authored
Merge pull request #36 from data-for-good-concepts/33-write-onboarding-documentation
33 write onboarding documentation
2 parents bb509f5 + f4ed7ef commit eac5a2e

File tree

4 files changed

+106
-45
lines changed

4 files changed

+106
-45
lines changed

.github/workflows/deploy-cloudrun.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: 'Authenticate GCP 🔐'
2121
id: 'auth'
22-
uses: 'google-github-actions/auth@v0'
22+
uses: 'google-github-actions/auth@v1'
2323
with:
2424
credentials_json: '${{ secrets.GC_SA_ADMNIN_KEY }}'
2525

README.Rmd

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ knitr::opts_chunk$set(
2424

2525
## Overview
2626

27-
> _⚠️ Please note, that the documentation of this project is still
27+
> ⚠️ _Please note, that the documentation of this project is still
2828
**Work In Progress**. The description might be incomplete and is subject to
2929
constant change._
3030

@@ -46,19 +46,26 @@ web service makes it accessible, easy to interact and easy to intergrate into
4646
other applications. You can communicate with this application through
4747
a `REST` API, which is possible using any modern programming language.
4848

49-
## Prerequisites
49+
## Architecture
50+
51+
<p align="center">
52+
<img src="man/figures/architecture.png" width="85%" alt="scraper web service architecture"/>
53+
</p>
5054

51-
- [Firefox](https://www.mozilla.org/)
52-
- [gcloud CLI](https://cloud.google.com/sdk/docs/install)
55+
## Prerequisites
5356

54-
When running this project locally, make sure to have a `Firefox` client
55-
installed on your machine. In order to deploy this web service on Google Cloud
56-
from the terminal, you will also need to install the `gcloud CLI`. When using a
57-
depolyed version of this project, you don't need to worry about the `Firefox`
58-
client, as it will be installed as part of the `Docker` image.
57+
- In order to run this service locally, you need to have a [Firefox](https://www.mozilla.org/) client installed on your machine.
58+
- In order to deploy this image on Google Cloud, you will need a [Google Cloud Account](https://cloud.google.com/) and a project.
59+
- You then also must [enable the Cloud Build API](https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com)
60+
as well and [enable the Cloud Run API](https://console.cloud.google.com/apis/library/run.googleapis.com).
61+
- To deploy this service from the command line you need to install [gcloud CLI](https://cloud.google.com/sdk/docs/install).
62+
- To deploy this service using `GitHub Actions` you need to export `Service
63+
Account` credentials. See [Using GitHub Actions](#using-github-actions) for more information.
5964

65+
When using a depolyed version of this project, you don't need to worry about the
66+
`Firefox` client, as it will be installed as part of the `Docker` image.
6067
Further, following tools and technologies will be highlighted or are heavily in
61-
use as part of this example - `RSelenium`, `plumber`, `Docker`,
68+
use as part of this concept - `RSelenium`, `plumber`, `Docker`,
6269
`Google Cloud Build`, `Google Cloud Run` and `GitHub Actions`.
6370

6471
## Usage
@@ -119,22 +126,15 @@ As a response the scraping service will return the requested dataset as `JSON`.
119126

120127
## Deployment
121128

129+
> ℹ️️️️️ _Documentation on IAM permissions need to be added. Further documentation
130+
on Service Account usage and permissions is currently missing._
131+
122132
The following steps will walk you through the steps to create a `build` of this
123133
project using [`Google Cloud Build`](https://cloud.google.com/build/docs/overview#:~:text=Cloud%20Build%20is%20a%20service,Docker%20containers%20or%20Java%20archives.) and then deploy it on [`Google Cloud Run`](https://cloud.google.com/run/docs/overview/what-is-cloud-run).
124134

125-
In order to deploy this web service on Google Cloud, please make sure you have a
126-
[Google Cloud Account](https://cloud.google.com/). Create a project within your
127-
account and enable the [`Cloud Build API`](https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com)
128-
as well as the [`Cloud Run API`](https://console.cloud.google.com/apis/library/run.googleapis.com).
129-
To deploy this service from the command line, you will further
130-
need to install the [`gcloud CLI`](https://cloud.google.com/sdk/docs/install).
131-
132135
In case you want to modify deployment parameters, feel free to adjust the
133136
`cloudbuild.yaml` according to your needs.
134137

135-
> _⚠️ Documentation on IAM permissions need to be added. Further documentation
136-
on Service Account usage and permissions is currently missing._
137-
138138
### Using the terminal
139139

140140
Once `gcloud CLI` is installed, execute the following command in the terminal
@@ -171,6 +171,34 @@ Docker images. Once the build is done, you will see your deployment on the
171171

172172
### Using GitHub Actions
173173

174+
The `GitHub Actions` workflow in this project is setup in a way, that with every
175+
`push` to the `main` branch the `deploy-cloudrun` workflow will be triggered.
176+
That workflow will automatically build the image in `Cloud Build` and deploy it
177+
on `Cloud Run`.
178+
179+
```{yaml, eval=FALSE}
180+
name: deploy-cloudrun
181+
on:
182+
push:
183+
branches:
184+
- 'main'
185+
...
186+
```
187+
188+
The `deploy-cloudrun` workflow uses the `google-github-actions/auth@v0` with a
189+
`Service Account JSON key` to authenticate with Google Cloud. The `JSON` key
190+
is stored as a Github secret and is named `GC_SA_ADMNIN_KEY`.
191+
192+
```{yaml, eval=FALSE}
193+
- name: 'Authenticate GCP 🔐'
194+
id: 'auth'
195+
uses: 'google-github-actions/auth@v1'
196+
with:
197+
credentials_json: '${{ secrets.GC_SA_ADMNIN_KEY }}'
198+
```
199+
200+
Once the workflow is done, you will see your deployment on the [Cloud Run Overview](https://console.cloud.google.com/run).
201+
174202
---
175203
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
176204
By participating in this project you agree to abide by its terms.

README.md

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ experimental](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimenta
1414

1515
## Overview
1616

17-
> *⚠️ Please note, that the documentation of this project is still
17+
> ⚠️ *Please note, that the documentation of this project is still
1818
> **Work In Progress**. The description might be incomplete and is
1919
> subject to constant change.*
2020
@@ -40,21 +40,34 @@ to intergrate into other applications. You can communicate with this
4040
application through a `REST` API, which is possible using any modern
4141
programming language.
4242

43+
## Architecture
44+
45+
<p align="center">
46+
<img src="man/figures/architecture.png" width="85%" alt="scraper web service architecture"/>
47+
</p>
48+
4349
## Prerequisites
4450

45-
- [Firefox](https://www.mozilla.org/)
46-
- [gcloud CLI](https://cloud.google.com/sdk/docs/install)
51+
- In order to run this service locally, you need to have a
52+
[Firefox](https://www.mozilla.org/) client installed on your machine.
53+
- In order to deploy this image on Google Cloud, you will need a [Google
54+
Cloud Account](https://cloud.google.com/) and a project.
55+
- You then also must [enable the Cloud Build
56+
API](https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com)
57+
as well and [enable the Cloud Run
58+
API](https://console.cloud.google.com/apis/library/run.googleapis.com).
59+
- To deploy this service from the command line you need to install
60+
[gcloud CLI](https://cloud.google.com/sdk/docs/install).
61+
- To deploy this service using `GitHub Actions` you need to export
62+
`Service Account` credentials. See [Using GitHub
63+
Actions](#using-github-actions) for more information.
4764

48-
When running this project locally, make sure to have a `Firefox` client
49-
installed on your machine. In order to deploy this web service on Google
50-
Cloud from the terminal, you will also need to install the `gcloud CLI`.
5165
When using a depolyed version of this project, you don’t need to worry
5266
about the `Firefox` client, as it will be installed as part of the
53-
`Docker` image.
54-
55-
Further, following tools and technologies will be highlighted or are
56-
heavily in use as part of this example - `RSelenium`, `plumber`,
57-
`Docker`, `Google Cloud Build`, `Google Cloud Run` and `GitHub Actions`.
67+
`Docker` image. Further, following tools and technologies will be
68+
highlighted or are heavily in use as part of this concept - `RSelenium`,
69+
`plumber`, `Docker`, `Google Cloud Build`, `Google Cloud Run` and
70+
`GitHub Actions`.
5871

5972
## Usage
6073

@@ -115,28 +128,19 @@ As a response the scraping service will return the requested dataset as
115128

116129
## Deployment
117130

131+
> ℹ️️️️️ *Documentation on IAM permissions need to be added. Further
132+
> documentation on Service Account usage and permissions is currently
133+
> missing.*
134+
118135
The following steps will walk you through the steps to create a `build`
119136
of this project using
120137
[`Google Cloud Build`](https://cloud.google.com/build/docs/overview#:~:text=Cloud%20Build%20is%20a%20service,Docker%20containers%20or%20Java%20archives.)
121138
and then deploy it on
122139
[`Google Cloud Run`](https://cloud.google.com/run/docs/overview/what-is-cloud-run).
123140

124-
In order to deploy this web service on Google Cloud, please make sure
125-
you have a [Google Cloud Account](https://cloud.google.com/). Create a
126-
project within your account and enable the
127-
[`Cloud Build API`](https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com)
128-
as well as the
129-
[`Cloud Run API`](https://console.cloud.google.com/apis/library/run.googleapis.com).
130-
To deploy this service from the command line, you will further need to
131-
install the [`gcloud CLI`](https://cloud.google.com/sdk/docs/install).
132-
133141
In case you want to modify deployment parameters, feel free to adjust
134142
the `cloudbuild.yaml` according to your needs.
135143

136-
> *⚠️ Documentation on IAM permissions need to be added. Further
137-
> documentation on Service Account usage and permissions is currently
138-
> missing.*
139-
140144
### Using the terminal
141145

142146
Once `gcloud CLI` is installed, execute the following command in the
@@ -176,6 +180,35 @@ Overview](https://console.cloud.google.com/run).
176180

177181
### Using GitHub Actions
178182

183+
The `GitHub Actions` workflow in this project is setup in a way, that
184+
with every `push` to the `main` branch the `deploy-cloudrun` workflow
185+
will be triggered. That workflow will automatically build the image in
186+
`Cloud Build` and deploy it on `Cloud Run`.
187+
188+
``` yaml
189+
name: deploy-cloudrun
190+
on:
191+
push:
192+
branches:
193+
- 'main'
194+
...
195+
```
196+
197+
The `deploy-cloudrun` workflow uses the `google-github-actions/auth@v0`
198+
with a `Service Account JSON key` to authenticate with Google Cloud. The
199+
`JSON` key is stored as a Github secret and is named `GC_SA_ADMNIN_KEY`.
200+
201+
``` yaml
202+
- name: 'Authenticate GCP 🔐'
203+
id: 'auth'
204+
uses: 'google-github-actions/auth@v1'
205+
with:
206+
credentials_json: '${{ secrets.GC_SA_ADMNIN_KEY }}'
207+
```
208+
209+
Once the workflow is done, you will see your deployment on the [Cloud
210+
Run Overview](https://console.cloud.google.com/run).
211+
179212
------------------------------------------------------------------------
180213
181214
Please note that this project is released with a [Contributor Code of

man/figures/architecture.png

163 KB
Loading

0 commit comments

Comments
 (0)