In this repository we can find reusable workflows that can be used from within other repositories in this organization. Here's the shared workflows we can find in this repository:
- 1. Build And Push Docker
- 2. Build And Push Helm
- 3. Pull Request
- 4. Release On Tag Push
- 5. Update Artifacts File
This workflow builds a docker image and and pushes it to the registry.
This workflow also utilizes update-artifact-file
workflow, to edit the artifacts.yaml
file in the common helm charts repository.
Name | Description | Type | Required? | Default Value |
---|---|---|---|---|
scope | This is the subdirectory in the helm-charts repository: helm-charts/<scope> |
string | no | '' |
repository | If you want to override default's docker image name | string | no | |
context | From where the CI should build the docker image | string | no | . (Current context) |
%%{
init: {
'theme': 'forest',
'themeVariables': {
'lineColor': '#F8B229'
}
}
}%%
flowchart TD
classDef head fill:#5882FA
classDef workflow fill:#8258FA
A[Build And Push Docker]:::head -->|INPUTS: \n scope \n repository \n context| B[Checkout latest commit]
B --> C(Login to Remote Registry)
C --> D("Generate Docker Image Name \n (using repository and context)")
D --> E( Build Image)
E --> F[Push Image]
F -->|scope != #quot;#quot;| G[Trigger update-artifacts-file workflow]:::workflow
This workflow package a helm chart and and pushes it to the registry.
This workflow also utilizes update-artifact-file
workflow, to edit the artifacts.yaml
file in the common helm charts repository.
Helm chart's name and version are inferred automatically from the Chart.yaml
file.
Name | Description | Type | Required? | Default Value |
---|---|---|---|---|
scope | This is the subdirectory in the helm-charts repository: helm-charts/<scope> |
string | no | '' |
%%{
init: {
'theme': 'forest',
'themeVariables': {
'lineColor': '#F8B229'
}
}
}%%
flowchart TD
classDef head fill:#5882FA
classDef workflow fill:#8258FA
A[Build And Push Helm]:::head -->|INPUTS: \n scope| B[Checkout latest commit]
B --> C[Setup Helm]
C --> D[Login to Remote Registry]
D --> E(Retrieve Chart Name)
E --> F[Retrieve Chart Version]
F --> G[Package Chart into TGZ]
G --> H[Publish Chart to ACR]
H -->|scope != #quot;#quot;| I[Trigger update-artifacts-file workflow]:::workflow
This workflow should be used in your pull requests; here linters run, Snyk checks for vulnerabilities, tests of the service, and a dummy docker build to check that docker image can be still built and hasn't broken.
Name | Description | Type | Required? | Default Value |
---|---|---|---|---|
enableOpenApiCheck | Flag to enable OpenAPI lint checks | boolean | no | true |
openApiFilePath | Path to the OpenAPI file (if enableOpenApiCheck is true) | string | no | ./openapi3.yaml |
usePostgres | Flag whether to initiate postgres service or not | boolean | no | false |
%%{
init: {
'theme': 'forest',
'themeVariables': {
'lineColor': '#F8B229'
}
}
}%%
flowchart TD
classDef parent fill:#f946
classDef head fill:#5882FA
A[Pull Request]:::head -->|INPUTS: \n enableOpenApiCheck \n openApiFilePath \n usePostgres| B[Jobs]
B --> C[ESLint Job]:::parent
C --> D[Checkout Git repository]
D --> E[Set up Node.js]
E --> F[Install dependencies]
F --> G[Run linters]
G -->|enableOpenApiCheck==true| H[Lint Checks on OpenAPI File]
B --> I[Security Job]:::parent
I --> J[Checkout Git repository]
J --> K[Run Snyk to check for vulnerabilities]
B --> L[Tests Job]:::parent
L -->|usePostgres==true| N[Start Postgres]
L -->|usePostgres==false| O[Checkout Git repository]
N --> O
O --> P[Set up Node.js]
P --> Q[Install Node.js dependencies]
Q --> R[Run tests]
R --> S[Upload Test Reporters]
B --> T[Build Image Job]:::parent
T --> U[Checkout Git repository]
U --> V[Build Docker image]
This workflow creates a release. Its trigger event should be when a new tag is craeted in the repository. This workflow generates postman collection for the service, and modifies the CHANGELOG.md
file respectively.
Name | Description | Type | Required? | Default Value |
---|---|---|---|---|
enableOpenApiToPostman | Flag to enable OpenAPI to Postman collection conversion | boolean | no | true |
%%{
init: {
'theme': 'forest',
'themeVariables': {
'lineColor': '#F8B229'
}
}
}%%
flowchart TD
classDef head fill:#5882FA
A[Release On Tag Push]:::head -->|INPUTS: \n enableOpenApiToPostman| C["Checkout Git repository for CHANGELOG.md \n (for release notes)"]
C --> D[Get package info]
D --> E["Setup Node.js \n (for postman collection)"]
E --> F[Set Collection File Name Env]
F -->|enableOpenApiToPostman==true| G[Add openapi to Postman Collection]
G --> H[Publish Release to GitHub]
F --> |else| H
This workflow edits the artifacts.json
according to the input.
Name | Description | Type | Required? | Default Value |
---|---|---|---|---|
scope | This is the subdirectory in the helm-charts repository: helm-charts/<scope> |
string | yes | |
type | Artifact`s type | string | no | docker |
artifact-name | Artifact`s name | string | yes | |
artifact-tag | Aritfact`s tag | string | yes |
%%{
init: {
'theme': 'forest',
'themeVariables': {
'lineColor': '#F8B229'
}
}
}%%
flowchart TD
classDef head fill:#5882FA
A[Edit artifacts.json in helm-charts]:::head -->|INPUTS: \n artifact-name \n artifact-tag| D["Checkout helm-charts Repository \n (access the helm-charts repository for modification)"]
D --> E[Set up Node.js]
E -->|using the inputs| F["Modify artifacts.json \n (update artifacts.json with new artifact data)"]
F --> G["Commit Changes \n (commit and push the updated artifacts.json back to the repository)"]