Skip to content

Commit de24291

Browse files
authored
Merge pull request #34 from IFRCGo/changes_in_pipelines
changes to implement qa and production env
2 parents dae020e + 7d211d9 commit de24291

File tree

5 files changed

+276
-1
lines changed

5 files changed

+276
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Production pipeline
2+
3+
on:
4+
workflow_dispatch: # Allows manual execution
5+
6+
jobs:
7+
build-and-deploy:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: 'Checkout GitHub Action'
11+
uses: actions/checkout@main
12+
13+
- name: 'Login via Azure CLI'
14+
uses: azure/login@v1
15+
with:
16+
creds: ${{ secrets.AZURE_CREDENTIALS }}
17+
18+
- name: 'Set up Kubernetes'
19+
uses: azure/aks-set-context@v2
20+
with:
21+
creds: ${{ secrets.AZURE_CREDENTIALS }}
22+
cluster-name: ${{ secrets.AKS_CLUSTER_NAME }}
23+
resource-group: ${{ secrets.AKS_RESOURCE_GROUP }}
24+
25+
- name: 'Build and push image'
26+
uses: azure/docker-login@v1
27+
with:
28+
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
29+
username: ${{ secrets.REGISTRY_USERNAME }}
30+
password: ${{ secrets.REGISTRY_PASSWORD }}
31+
- run: |
32+
docker build -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:${{ github.sha }} -f ./docker/Dockerfile .
33+
docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:${{ github.sha }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:latest
34+
35+
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:${{ github.sha }}
36+
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi:latest
37+
- name: 'Copy production values files'
38+
run: |
39+
cp ./helm-chart/values-production.yaml ./helm-chart/values.yaml
40+
41+
- name: 'Deploy to AKS with Helm'
42+
run: |
43+
helm upgrade --install whatnow ./helm-chart \
44+
--namespace ${{ secrets.AKS_CLUSTER_NAMESPACE }} \
45+
--create-namespace
46+
47+

.github/workflows/qa-pipeline.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Stage pipeline
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- 'staging'
9+
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: 'Checkout GitHub Action'
16+
uses: actions/checkout@main
17+
18+
- name: 'Login via Azure CLI'
19+
uses: azure/login@v1
20+
with:
21+
creds: ${{ secrets.AZURE_CREDENTIALS }}
22+
23+
- name: 'Set up Kubernetes'
24+
uses: azure/aks-set-context@v2
25+
with:
26+
creds: ${{ secrets.AZURE_CREDENTIALS }}
27+
cluster-name: ${{ secrets.AKS_CLUSTER_NAME }}
28+
resource-group: ${{ secrets.AKS_RESOURCE_GROUP }}
29+
30+
- name: 'Build and push image'
31+
uses: azure/docker-login@v1
32+
with:
33+
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
34+
username: ${{ secrets.REGISTRY_USERNAME }}
35+
password: ${{ secrets.REGISTRY_PASSWORD }}
36+
- run: |
37+
docker build -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:${{ github.sha }} -f ./docker/Dockerfile .
38+
docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:${{ github.sha }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:latest
39+
40+
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:${{ github.sha }}
41+
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/whatnowapi-qa:latest
42+
43+
- name: 'Copy staging values file'
44+
run: |
45+
cp ./helm-chart/values-staging.yaml ./helm-chart/values.yaml
46+
47+
- name: 'Deploy to AKS with Helm'
48+
run: |
49+
helm upgrade --install whatnow-qa ./helm-chart \
50+
--namespace ${{ secrets.AKS_CLUSTER_NAMESPACE_QA }} \
51+
--create-namespace
52+
53+

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ Homestead.yaml
1919
npm-debug.log
2020
yarn-error.log
2121
helm-chart/secrets.yml
22-
.idea/*
22+
.idea/*
23+
helm-chart/fullchain.pem
24+
helm-chart/privkey.pem
25+
helm-chart/secrets.yml
26+
helm-chart/secrets-ifrc.yml
27+
helm-chart/secrets-qa.yml
28+
helm-chart/secrets-prod.yml
29+
helm-chart/ssl-secret.yaml
30+
.DS_Store

helm-chart/values-production.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Azure Container Registry details
2+
image:
3+
repository: ifrcsmdb.azurecr.io/whatnowapi
4+
tag: "latest"
5+
pullPolicy: Always
6+
7+
replicaCount: 1
8+
9+
# Kubernetes service configuration
10+
service:
11+
type: ClusterIP
12+
port: 80
13+
targetPort: 80
14+
# Environment variables
15+
env:
16+
APP_NAME: 'IFRC National Society Preparedness Messages'
17+
APP_ENV: production
18+
APP_DEBUG: false
19+
APP_LOG_LEVEL: info
20+
APP_URL: https://api-preparemessages.ifrc.org
21+
LOG_CHANNEL: stack
22+
DB_PORT: 3306
23+
DB_CONNECTION: mysql
24+
BROADCAST_DRIVER: log
25+
CACHE_DRIVER: file
26+
QUEUE_CONNECTION: sync
27+
SESSION_DRIVER: file
28+
SESSION_LIFETIME: 120
29+
REDIS_HOST: 127.0.0.1
30+
REDIS_PASSWORD: null
31+
REDIS_PORT: 6379
32+
MAIL_DRIVER: smtp
33+
MAIL_HOST: smtp.mailtrap.io
34+
MAIL_PORT: 2525
35+
MAIL_USERNAME: null
36+
MAIL_PASSWORD: null
37+
MAIL_ENCRYPTION: null
38+
AWS_ACCESS_KEY_ID:
39+
AWS_SECRET_ACCESS_KEY:
40+
AWS_DEFAULT_REGION: us-east-1
41+
AWS_BUCKET:
42+
PUSHER_APP_ID:
43+
PUSHER_APP_KEY:
44+
PUSHER_APP_SECRET:
45+
PUSHER_APP_CLUSTER: mt1
46+
MIX_PUSHER_APP_KEY: "${PUSHER_APP_KEY}"
47+
MIX_PUSHER_APP_CLUSTER: "${PUSHER_APP_CLUSTER}"
48+
AZURE_STORAGE_ACCOUNT: smdbstorageaccount
49+
AZURE_STORAGE_CONTAINER: images
50+
AZURE_STORAGE_DOMAIN: blob.core.windows.net
51+
52+
secrets:
53+
dbSecretName: admin-credentials
54+
variables:
55+
ADMIN_USER: ADMIN_USER
56+
ADMIN_PASSWORD: ADMIN_PASSWORD
57+
DB_HOST: DB_HOST
58+
DB_DATABASE: DB_DATABASE
59+
DB_USERNAME: DB_USERNAME
60+
DB_PASSWORD: DB_PASSWORD
61+
APP_KEY: APP_KEY
62+
AZURE_STORAGE_KEY: AZURE_STORAGE_KEY
63+
AZURE_STORAGE_CONNECTION_STRING: AZURE_STORAGE_CONNECTION_STRING
64+
65+
# Ingress (if using)
66+
ingress:
67+
enabled: true
68+
annotations:
69+
kubernetes.io/ingress.class: nginx
70+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
71+
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
72+
hosts:
73+
- host: "api.whatnow"
74+
paths:
75+
- path: /
76+
pathType: ImplementationSpecific
77+
- host: "api-preparemessages.ifrc.org"
78+
paths:
79+
- path: /
80+
pathType: Prefix
81+
tls:
82+
- hosts:
83+
- "api-preparemessages.ifrc.org"
84+
secretName: "ifrc.certificates.secret"

helm-chart/values-staging.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Azure Container Registry details
2+
image:
3+
repository: ifrcsmdb.azurecr.io/whatnowapi-qa
4+
tag: "latest"
5+
pullPolicy: Always
6+
7+
replicaCount: 1
8+
9+
# Kubernetes service configuration
10+
service:
11+
type: ClusterIP
12+
port: 80
13+
targetPort: 80
14+
# Environment variables
15+
env:
16+
APP_NAME: Laravel
17+
APP_ENV: stage
18+
APP_DEBUG: false
19+
APP_URL: http://localhost
20+
LOG_CHANNEL: stack
21+
DB_PORT: 3306
22+
DB_CONNECTION: mysql
23+
BROADCAST_DRIVER: log
24+
CACHE_DRIVER: file
25+
QUEUE_CONNECTION: sync
26+
SESSION_DRIVER: file
27+
SESSION_LIFETIME: 120
28+
REDIS_HOST: 127.0.0.1
29+
REDIS_PASSWORD: null
30+
REDIS_PORT: 6379
31+
MAIL_DRIVER: smtp
32+
MAIL_HOST: smtp.mailtrap.io
33+
MAIL_PORT: 2525
34+
MAIL_USERNAME: null
35+
MAIL_PASSWORD: null
36+
MAIL_ENCRYPTION: null
37+
AWS_ACCESS_KEY_ID:
38+
AWS_SECRET_ACCESS_KEY:
39+
AWS_DEFAULT_REGION: us-east-1
40+
AWS_BUCKET:
41+
PUSHER_APP_ID:
42+
PUSHER_APP_KEY:
43+
PUSHER_APP_SECRET:
44+
PUSHER_APP_CLUSTER: mt1
45+
MIX_PUSHER_APP_KEY: "${PUSHER_APP_KEY}"
46+
MIX_PUSHER_APP_CLUSTER: "${PUSHER_APP_CLUSTER}"
47+
AZURE_STORAGE_ACCOUNT: smdbstorageaccount
48+
AZURE_STORAGE_CONTAINER: images-stage
49+
AZURE_STORAGE_DOMAIN: blob.core.windows.net
50+
51+
secrets:
52+
dbSecretName: admin-credentials
53+
variables:
54+
ADMIN_USER: ADMIN_USER
55+
ADMIN_PASSWORD: ADMIN_PASSWORD
56+
DB_HOST: DB_HOST
57+
DB_DATABASE: DB_DATABASE
58+
DB_USERNAME: DB_USERNAME
59+
DB_PASSWORD: DB_PASSWORD
60+
APP_KEY: APP_KEY
61+
AZURE_STORAGE_KEY: AZURE_STORAGE_KEY
62+
AZURE_STORAGE_CONNECTION_STRING: AZURE_STORAGE_CONNECTION_STRING
63+
64+
# Ingress (if using)
65+
ingress:
66+
enabled: true
67+
annotations:
68+
kubernetes.io/ingress.class: nginx
69+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
70+
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
71+
hosts:
72+
- host: "qa.api.whatnow"
73+
paths:
74+
- path: /
75+
pathType: ImplementationSpecific
76+
- host: "api-preparemessages-stage.ifrc.org"
77+
paths:
78+
- path: /
79+
pathType: Prefix
80+
tls:
81+
- hosts:
82+
- "api-preparemessages-stage.ifrc.org"
83+
secretName: "ifrc.certificates.secret"

0 commit comments

Comments
 (0)