Skip to content

Commit f9b774e

Browse files
anmolnagpalVishwajitNagulkarAshutoshAM2002Nikita Dugar
authored
Issue 357 (#28)
Co-authored-by: Vishwajit Nagulkar <[email protected]> Co-authored-by: vishwajitnagulkar <[email protected]> Co-authored-by: Ashutosh Mahajan <[email protected]> Co-authored-by: Ashutosh Mahajan <[email protected]> Co-authored-by: Nikita Dugar <[email protected]>
1 parent 14ebc28 commit f9b774e

File tree

6 files changed

+250
-64
lines changed

6 files changed

+250
-64
lines changed

.github/workflows/docker.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: docker-build-push
33
on:
44
workflow_call:
55
inputs:
6-
user:
6+
registry:
77
required: true
88
type: string
99
images:
@@ -15,24 +15,21 @@ on:
1515
ECR_REPOSITORY:
1616
required: true
1717
type: string
18-
registry:
19-
required: true
20-
type: string
2118
IMAGE_TAG:
2219
required: true
2320
type: string
2421

2522
secrets:
26-
aws-access-key-id:
23+
AWS_ACCESS_KEY_ID:
2724
description: 'aws access keys'
2825
required: true
29-
aws-secret-access-key:
26+
AWS_SECRET_ACCESS_KEY:
3027
description: 'aws secret access keys'
3128
required: true
32-
dockerhub-username:
29+
DOCKERHUB_USERNAME:
3330
description: 'dockerhub username'
3431
required: true
35-
dockerhub-password:
32+
DOCKERHUB_PASSWORD:
3633
description: 'dockerhub password'
3734
required: true
3835

@@ -49,8 +46,8 @@ jobs:
4946
- name: Login to Docker Hub
5047
uses: docker/login-action@v2
5148
with:
52-
username: ${{ secrets.dockerhub-username }}
53-
password: ${{ secrets.dockerhub-password }}
49+
username: ${{ secrets.DOCKERHUB_USERNAME }}
50+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
5451

5552
- name: Push docker image to DOCKERHUB
5653
if: ${{ inputs.registry == 'DOCKERHUB' }}
@@ -64,8 +61,8 @@ jobs:
6461
- name: Configure AWS credentials
6562
uses: aws-actions/configure-aws-credentials@v2
6663
with:
67-
aws-access-key-id: ${{ secrets.aws-access-key-id }}
68-
aws-secret-access-key: ${{ secrets.aws-secret-access-key }}
64+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
65+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
6966
aws-region: ${{ inputs.aws-region }}
7067

7168
- name: Login to Amazon ECR

.github/workflows/helm.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,22 @@ on:
77
required: true
88
type: string
99
description: 'Cloud provider to run the workflow. e.g. azure or aws'
10-
aws-region:
11-
required: false
12-
type: string
13-
description: 'AWS EKS cluster region'
1410
eks-cluster-name:
1511
required: false
1612
type: string
1713
description: 'EKS cluster name'
18-
resource-group:
14+
aws-region:
1915
required: false
2016
type: string
21-
description: 'Container for managing Azure resources'
17+
description: 'AWS EKS cluster region'
2218
azure-cluster-name:
2319
required: false
2420
type: string
2521
description: 'Azure cluster name'
26-
namespace:
22+
resource-group:
2723
required: false
2824
type: string
29-
description: 'Boundary for Kubernetes resources'
25+
description: 'Container for managing Azure resources'
3026
helm-chart-directory:
3127
required: true
3228
type: string
@@ -35,14 +31,11 @@ on:
3531
required: false
3632
type: string
3733
description: 'Unique ID for installed chart'
38-
rollback:
39-
required: false
40-
type: string
41-
description: 'Environment name for rollback'
4234
timeout:
4335
required: true
4436
type: string
4537
description: 'Timeout for helm install step in seconds'
38+
default: '120s'
4639
set-parameters:
4740
required: false
4841
type: string
@@ -55,6 +48,15 @@ on:
5548
required: true
5649
type: number
5750
description: 'number of revisions stored in the revision history.'
51+
default: '7'
52+
namespace:
53+
required: false
54+
type: string
55+
description: 'Boundary for Kubernetes resources'
56+
rollback:
57+
required: false
58+
type: string
59+
description: 'Environment name for rollback'
5860
secrets:
5961
aws-access-key-id:
6062
description: 'AWS Access Key ID'

README.md

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,37 @@
1-
<h1 align="center">github-shared-workflows</h1>
1+
<h1 align="center">GitHub-Shared-Workflows</h1>
2+
<p align="center">
3+
GitHub shared workflow defines a workflow that we can use in multiple repos with a simple structure.
4+
</p>
25

3-
## SST Workflow
4-
5-
This workflow is used to deploy serverless stack (SST) application on AWS environment. Workflows have been added in `.github/workflows/sst_workflow.yml`.
6-
7-
Below workflow can be used to deploy SST in preview environment when pull request generated and it destroys the preview environment when pull request closed, merged and labeled as destroy, similarly staging and production is deployed using there defined branches.
6+
This repo offers to using a workflow with a simple calling structure and proper documentation. This shared workflow feature can overcome the issue of upgrading hundreds of workflows whenever any new updation is required. In this repo, we have many kinds of workflows related to Terraform, Kubernetes, Helm, SST, and regular workflows like maintain changelog, auto assignee, and many more.
87

8+
## How shared workflow use
99
```yaml
10-
name: SST Workflow
11-
12-
on:
13-
pull_request:
14-
types: [closed, merged, labeled]
15-
workflow_dispatch:
1610
jobs:
17-
preview:
18-
uses: clouddrove/github-shared-workflows/.github/workflows/sst_workflow.yml@master
19-
with:
20-
app-env: # preview
21-
working-directory: # specify your working folder from repo
11+
staging: # Job name
12+
uses: clouddrove/github-shared-workflows/.github/workflows/example.yml@master
2213
secrets:
23-
aws-access-key-id: # AWS Access Key ID for preview
24-
aws-secret-access-key: # AWS Secret Access Key for preview
25-
26-
staging:
27-
if: ${{ github.base_ref == 'stage' }}
28-
uses: clouddrove/github-shared-workflows/.github/workflows/sst_workflow.yml@master
14+
SECRET_1:
15+
SECRET_2:
2916
with:
30-
app-env: # stage
31-
working-directory: # specify your working folder from repo
32-
secrets:
33-
aws-access-key-id: # AWS Access Key ID for stage
34-
aws-secret-access-key: # AWS Secret Access Key for stage
35-
36-
production:
37-
if: ${{ github.base_ref == 'master' }}
38-
uses: clouddrove/github-shared-workflows/.github/workflows/sst_workflow.yml@master
39-
with:
40-
app-env: # prod
41-
working-directory: # specify your working folder from repo
42-
secrets:
43-
aws-access-key-id: # AWS Access Key ID for prod
44-
aws-secret-access-key: # AWS Secret Access Key for prod
17+
input_1:
18+
input_2:
4519
```
20+
Above example is just a simple example to call workflow from github shared workflow to your workflow and used in the jobs as per your requirements.
21+
22+
## 🚀 Table Of Content
23+
1. [SST Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/sst.md)
24+
2. [Helm Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/helm.md)
25+
* [Example for AWS cloud provider](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/helm.md#example-for-aws-cloud-provider)
26+
* [Example for Azure cloud provider](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/helm.md#example-for-azure-cloud-provider)
27+
3. [Docker Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/docker.md)
28+
* [Example for scan and push docker image on Dockerhub](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/docker.md#example-for-scan-and-push-docker-image-on-dockerhub)
29+
* [Example for scan and push docker image on ECR](https://github.com/clouddrove/github-shared-workflows/blob/master/docs/docker.md#example-for-scan-and-push-docker-image-on-ecr)
30+
4631
## Feedback
47-
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-azure-aks/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).
32+
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/github-shared-workflows/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).
4833
49-
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-azure-aks)!
34+
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/github-shared-workflows)!
5035
5136
## About us
5237

docs/docker.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
## Docker Workflow
2+
#### [1. Docker Scanner workflow reference](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/docker-scanner.yml)
3+
#### [2. Docker push workflow reference](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/docker.yml)
4+
5+
This workflow scans the Docker image locally before pushing it to the Docker registry. Workflows have been added in `.github/workflows/docker-scanner.yml`.
6+
7+
#### Usage
8+
The following workflow can build and scan a Docker image locally, providing vulnerability results under the code scanning section of the security tab. It also allows you to choose which vulnerability should block the workflow before pushing the Docker image to the Docker registry this workflow support DOCKERHUB, ECR or both.
9+
10+
#### Example for scan and push docker image on Dockerhub
11+
12+
```yaml
13+
name: Docker Workflow
14+
# This permission are helpful for pushing vulnerability in security tab
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
statuses: write
20+
21+
on:
22+
workflow_dispatch:
23+
24+
jobs:
25+
docker-scanner:
26+
uses: clouddrove/github-shared-workflows/.github/workflows/docker-scanner.yml@master
27+
with:
28+
severity: # which vulnerability should disable the workflow before pusing image to registry. eg. 'HIGH,CRITICAL,MEDIUM,LOW'
29+
30+
docker-push:
31+
needs: docker-scanner
32+
if: ${{ success() && needs.docker-scanner.result == 'success' }} # This condition start this docker push workflow on succesfull scanning of docker image
33+
uses: clouddrove/github-shared-workflows/.github/workflows/docker.yml@master
34+
secrets:
35+
DOCKERHUB_USERNAME: # Dockerhub username
36+
DOCKERHUB_PASSWORD: # Dockerhub password
37+
with:
38+
registry: # DOCKERHUB
39+
images: # dockerhub repository name
40+
IMAGE_TAG: # image tag eg. ${{ github.run_number }}
41+
```
42+
43+
#### Example for scan and push docker image on ECR
44+
45+
```yaml
46+
name: Docker Workflow
47+
# This permission are helpful for pushing vulnerability in security tab
48+
permissions:
49+
actions: read
50+
contents: read
51+
security-events: write
52+
statuses: write
53+
54+
on:
55+
workflow_dispatch:
56+
57+
jobs:
58+
docker-scanner:
59+
uses: clouddrove/github-shared-workflows/.github/workflows/docker-scanner.yml@master
60+
with:
61+
severity: # which vulnerability should disable the workflow before pusing image to registry. eg. 'HIGH,CRITICAL,MEDIUM,LOW'
62+
63+
docker-push:
64+
needs: docker-scanner
65+
if: ${{ success() && needs.docker-scanner.result == 'success' }} # This condition start this docker push workflow on succesfull scanning of docker image
66+
uses: clouddrove/github-shared-workflows/.github/workflows/docker.yml@master
67+
secrets:
68+
AWS_ACCESS_KEY_ID: # AWS Access Key ID
69+
AWS_SECRET_ACCESS_KEY: # AWS Secret Access Key ID
70+
with:
71+
registry: # 'ECR'
72+
ECR_REPOSITORY: # ECR Repository name
73+
aws-region: # AWS region
74+
IMAGE_TAG: # image tag eg. ${{ github.run_number }}
75+
```

docs/helm.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
## [Helm Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/helm.yml)
2+
3+
This workflow is used to deploy and rollback Helm charts using GitHub Actions. It utilizes the workflows defined in `.github/workflows/helm.yml`
4+
5+
#### Usage
6+
The helm workflow can be triggered manually using the GitHub Actions workflow dispatch feature. It deploys or rollback Helm charts based on the specified inputs. Additionally, it also performs Helm template and Helm lint operations.
7+
To use the helm Workflow, add the following workflow definition to your `.github/workflows/helm.yml` file:
8+
9+
#### Example for AWS cloud provider
10+
11+
```yaml
12+
name: Helm Workflow AWS
13+
on:
14+
workflow_dispatch:
15+
inputs:
16+
environment:
17+
required: false
18+
type: choice
19+
description: Select Environment name
20+
options:
21+
- # This option is blank beacause we did not given name to helm deploy or you can give this name eg. deploy
22+
- rollback # GitHub manual workflow trigger with environment selection for rollback
23+
jobs:
24+
aws:
25+
uses: clouddrove/github-shared-workflows/.github/workflows/helm.yml@master
26+
secrets:
27+
AWS_ACCESS_KEY_ID: # AWS Access Key ID
28+
AWS_SECRET_ACCESS_KEY: # AWS Secret Access Key ID
29+
with:
30+
provider: # aws
31+
aws-region: # AWS region
32+
helm-chart-directory: # Helm chart directory from repo
33+
eks-cluster-name: # EKS cluster name
34+
release-name: # Helm chart realease name
35+
helm-chart-directory: # Helm chart directory from repo
36+
# Set parameter is optionals below format support set parameter
37+
set-parameters:
38+
# --set image.tag=latest
39+
# --set replicaCount=3
40+
# --set service.type=LoadBalancer
41+
timeout: # Timeout in seconds default values is 120s
42+
values-file-path: #Values file path
43+
history-max: # Revision history deafault values is 7
44+
namespace: # Namespace
45+
rollback: ${{ github.event.inputs.environment }} # Mandetory input do not change this
46+
```
47+
48+
#### Example for Azure cloud provider
49+
50+
```yaml
51+
name: Helm Workflow Azure
52+
on:
53+
workflow_dispatch:
54+
inputs:
55+
environment:
56+
required: false
57+
type: choice
58+
description: Select Environment name
59+
options:
60+
- # This option is blank beacause we did not given name to helm deploy or you can give this name eg. deploy
61+
- rollback # GitHub manual workflow trigger with environment selection for rollback
62+
jobs:
63+
azure:
64+
uses: clouddrove/github-shared-workflows/.github/workflows/helm.yml@master
65+
secrets:
66+
AZURE_CREDENTIALS: # Azure Credentials
67+
with:
68+
provider: # azure
69+
azure-cluster-name: # Azure cluster name
70+
resource-group: # Resource group name
71+
release-name: # Helm chart realease name
72+
helm-chart-directory: # Helm chart directory from repo
73+
# Set parameter is optionals below format support set parameters
74+
set-parameters:
75+
# --set image.tag=latest
76+
# --set replicaCount=3
77+
# --set service.type=LoadBalancer
78+
timeout: # Timeout in seconds default values is 120s
79+
values-file-path: #Values file path
80+
history-max: # Revision history deafault values is 7
81+
namespace: # Namespace
82+
rollback: ${{ github.event.inputs.environment }} # Mandetory input do not change this
83+
```

0 commit comments

Comments
 (0)