Skip to content

Commit 6e2af72

Browse files
Initial commit
0 parents  commit 6e2af72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2572
-0
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# DEFINE ALL YOUR ENVIRONMENT VARIABLES
2+
FACT_API_URL=
3+
FACT_API_TOKEN=

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @cloudbeds/data-insights
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Code Lint'
2+
description: Python code linter
3+
4+
runs:
5+
using: composite
6+
steps:
7+
8+
- name: Set up Python 3.10
9+
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435
10+
with:
11+
python-version: "3.10"
12+
13+
- name: Lint
14+
shell: bash
15+
run: |
16+
python -m pip install --upgrade pip
17+
pip install pre-commit && pre-commit install
18+
make lint
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'Unit Tests'
2+
description: Action to run the full suite of unit tests
3+
4+
runs:
5+
using: composite
6+
steps:
7+
8+
- name: Set up Python 3.10
9+
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435
10+
with:
11+
python-version: "3.10"
12+
13+
- name: Install dependencies
14+
shell: bash
15+
run: |
16+
pip install --upgrade pip
17+
pip install poetry
18+
poetry config virtualenvs.create false
19+
poetry install --no-interaction --no-ansi
20+
21+
- name: Test with pytest
22+
shell: bash
23+
run: |
24+
make unit-test

.github/workflows/dev.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Test, Build, and Publish to Dev Environment
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- dev
8+
9+
jobs:
10+
run-code-lint:
11+
name: Code Lint 🧹
12+
runs-on: default
13+
steps:
14+
- uses: actions/checkout@v5
15+
name: Checkout Repo
16+
- uses: ./.github/actions/code-lint
17+
name: Code Lint
18+
19+
run-unit-tests:
20+
name: Unit Testing 🧪
21+
runs-on: default
22+
permissions:
23+
id-token: write
24+
contents: read
25+
steps:
26+
27+
- name: Get GH app token
28+
id: gh-app-token
29+
uses: cloudbeds/composite-actions/gh-app-token@v2
30+
with:
31+
# replace <argocd-replace-with-your-repo> with the name of the argocd-repo that deploys your app
32+
repositories: >-
33+
["<argocd-replace-with-your-repo>"]
34+
# replace <placeholders with your project/squad GH app details>
35+
app_name: <github-app-name>
36+
37+
- uses: actions/checkout@v5
38+
name: Checkout Repo
39+
40+
- uses: ./.github/actions/unit-tests
41+
name: Run Unit Tests
42+
env:
43+
GITHUB_ACCESS_TOKEN: ${{ steps.gh-app-token.outputs.github-token }}
44+
45+
build-push:
46+
if: 0 # remove this line to enable this job
47+
name: Build and push image 🧱
48+
needs:
49+
- "run-unit-tests"
50+
- "run-code-lint"
51+
uses: ./.github/workflows/docker-build.yaml
52+
secrets: inherit
53+
with:
54+
push: true
55+
56+
update-deployment:
57+
if: 0 # remove this line to enable this job
58+
name: Update Deployment Manifest Image Tag 📜
59+
needs: build-push
60+
runs-on: x1-core
61+
steps:
62+
63+
- name: Get GH app token
64+
id: gh-app-token
65+
uses: cloudbeds/composite-actions/gh-app-token@v2
66+
with:
67+
# replace <argocd-replace-with-your-repo> with the name of the argocd-repo that deploys your app
68+
repositories: >-
69+
["<argocd-replace-with-your-repo>"]
70+
# replace <placeholders with your project/squad GH app details>
71+
app_name: <github-app-name>
72+
73+
- name: Update application on develop cluster
74+
uses: cloudbeds/[email protected]
75+
with:
76+
owner: cloudbeds
77+
repo: argo-${REPLACE_ME_WITH_YOUR_ARGO}
78+
github_token: ${{ steps.gh-app-token.outputs.github-token }}
79+
workflow_file_name: update-application.yaml
80+
client_payload: |
81+
{
82+
"cluster":
83+
"dev-ga",
84+
"app_name": "${{ github.event.repository.name }}",
85+
"image_tag": "${{ github.sha }}"
86+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build docker image
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
push:
7+
description: Indicates if the docker image has to be pushed
8+
type: boolean
9+
default: false
10+
outputs:
11+
image-tag:
12+
description: Image tag used
13+
value: ${{ github.event.pull_request.head.sha || github.sha }}
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
build:
21+
name: Docker Build 🐋
22+
runs-on: x1-core
23+
permissions:
24+
id-token: write
25+
contents: read
26+
packages: write
27+
steps:
28+
- name: Docker build
29+
uses: cloudbeds/composite-actions/docker/build-push/remote@v2
30+
with:
31+
push: ${{ inputs.push }}

.github/workflows/main.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Test, Build, and Publish to Stage Environment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
run-code-lint:
10+
name: Code Lint 🧹
11+
runs-on: default
12+
steps:
13+
- uses: actions/checkout@v5
14+
name: Checkout Repo
15+
- uses: ./.github/actions/code-lint
16+
name: Code Lint
17+
18+
run-unit-tests:
19+
name: Unit Testing 🧪
20+
runs-on: default
21+
permissions:
22+
id-token: write
23+
contents: read
24+
steps:
25+
- name: Get GH app token
26+
id: gh-app-token
27+
uses: cloudbeds/composite-actions/gh-app-token@v2
28+
with:
29+
# replace <argocd-replace-with-your-repo> with the name of the argocd-repo that deploys your app
30+
repositories: >-
31+
["<argocd-replace-with-your-repo>"]
32+
# replace <placeholders with your project/squad GH app details>
33+
app_name: <github-app-name>
34+
35+
- uses: actions/checkout@v5
36+
name: Checkout Repo
37+
- uses: ./.github/actions/unit-tests
38+
name: Run Unit Tests
39+
env:
40+
GITHUB_ACCESS_TOKEN: ${{ steps.gh-app-token.outputs.github-token }}
41+
42+
build-push:
43+
if: 0 # remove this line to enable this job
44+
name: Build and push image 🧱
45+
needs:
46+
- "run-unit-tests"
47+
- "run-code-lint"
48+
uses: ./.github/workflows/docker-build.yaml
49+
secrets: inherit
50+
with:
51+
push: true
52+
53+
update-deployment:
54+
if: 0 # remove this line to enable this job
55+
name: Triggers action to update ArgoCD application deployment manifest with new image tag
56+
needs: build-push
57+
runs-on: x1-core
58+
permissions:
59+
id-token: write
60+
contents: read
61+
steps:
62+
63+
- name: Get GH app token
64+
id: gh-app-token
65+
uses: cloudbeds/composite-actions/gh-app-token@v2
66+
with:
67+
# replace <argocd-replace-with-your-repo> with the name of the argocd-repo that deploys your app
68+
repositories: >-
69+
["<argocd-replace-with-your-repo>"]
70+
# replace <placeholders with your project/squad GH app details>
71+
app_name: <github-app-name>
72+
73+
- name: Update application on stage cluster
74+
uses: cloudbeds/[email protected]
75+
with:
76+
owner: cloudbeds
77+
repo: argocd-${REPLACE_ME_WITH_YOUR_ARGO}
78+
github_token: ${{ steps.gh-app-token.outputs.github-token }}
79+
workflow_file_name: update-application.yaml
80+
client_payload: |
81+
{
82+
"cluster": "stage-ga",
83+
"app_name": "${{ github.event.repository.name }}",
84+
"image_tag": "${{ github.sha }}"
85+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Pull Request Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
run-code-lint:
9+
name: Code Lint 🧹
10+
runs-on: default
11+
steps:
12+
- uses: actions/checkout@v5
13+
name: Checkout Repo
14+
15+
- uses: ./.github/actions/code-lint
16+
name: Code Lint
17+
18+
run-unit-tests:
19+
name: Unit Testing 🧪
20+
runs-on: default
21+
permissions:
22+
id-token: write
23+
contents: read
24+
steps:
25+
- name: Get GH app token
26+
id: gh-app-token
27+
uses: cloudbeds/composite-actions/gh-app-token@v2
28+
with:
29+
# replace <argocd-replace-with-your-repo> with the name of the argocd-repo that deploys your app
30+
repositories: >-
31+
["<argocd-replace-with-your-repo>"]
32+
# replace <placeholders with your project/squad GH app details>
33+
app_name: <github-app-name>
34+
35+
- uses: actions/checkout@v5
36+
name: Checkout Repo
37+
38+
- uses: ./.github/actions/unit-tests
39+
name: Run Unit Tests
40+
env:
41+
GITHUB_ACCESS_TOKEN: ${{ steps.gh-app-token.outputs.github-token }}
42+
43+
build:
44+
name: Docker Build
45+
uses: ./.github/workflows/docker-build.yaml
46+
secrets: inherit
47+
with:
48+
push: false

.github/workflows/release-tag.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Re-tag images and Push
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
10+
re-tag:
11+
if: 0 # remove this line to enable this job
12+
name: Re-tag images
13+
runs-on: x1-core
14+
permissions:
15+
id-token: write
16+
contents: read
17+
steps:
18+
# Application Image
19+
- name: Re-tag application image
20+
uses: cloudbeds/composite-actions/docker/crane-re-tag/aws-ecr@v2
21+
with:
22+
image_name: ${{ github.event.repository.name }}
23+
src_tag: ${{ github.sha }}
24+
dst_tag: ${{ github.ref_name }}
25+
26+
update-deployment:
27+
if: 0 # remove this line to enable this job
28+
name: Triggers action to update ArgoCD application deployment manifest with new image tag
29+
needs: re-tag
30+
runs-on: x1-core
31+
environment: production
32+
permissions:
33+
id-token: write
34+
contents: read
35+
steps:
36+
37+
- name: Get GH app token
38+
id: gh-app-token
39+
uses: cloudbeds/composite-actions/gh-app-token@v2
40+
with:
41+
# replace <argocd-replace-with-your-repo> with the name of the argocd-repo that deploys your app
42+
repositories: >-
43+
["<argocd-replace-with-your-repo>"]
44+
# replace <placeholders with your project/squad GH app details>
45+
app_name: <github-app-name>
46+
47+
- name: Update application on production cluster
48+
uses: cloudbeds/[email protected]
49+
with:
50+
owner: cloudbeds
51+
repo: argocd-${REPLACE_ME_WITH_YOUR_ARGO}
52+
github_token: ${{ steps.gh-app-token.outputs.github-token }}
53+
workflow_file_name: update-application.yaml
54+
client_payload: |
55+
{
56+
"cluster": "prod-ga",
57+
"app_name": "${{ github.event.repository.name }}",
58+
"image_tag": "${{ github.ref_name }}"
59+
}

0 commit comments

Comments
 (0)