Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/workflow #25

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 101 additions & 2 deletions .github/workflows/solar-system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ on:
branches:
- main
- 'feature/*'

env:
MONGO_URI: mongodb+srv://supercluster.d83jj.mongodb.net/superData
MONGO_USERNAME: superuser
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}

jobs:
unit-testing:
name: Unit Testing
Expand All @@ -30,4 +34,99 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Mocha-Test-Result
path: test-results.xml
path: test-results.xml
docker:
permissions: #added
packages: write #added
runs-on: ubuntu-latest
needs:
#- code-coverage
- unit-testing
steps:
- uses: actions/checkout@v4
- uses: docker/[email protected]
with:
#registry: ghcr.io
registry: docker.io
#username: '${{ github.repository_owner }}'
username: 'seyiogunniran'
# password: '${{ secrets.GITHUB_TOKEN }}'
password: '${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}'
- uses: docker/build-push-action@v4
with:
context: .
push: true
tags: 'docker.io/seyiogunniran/solar-system:${{ github.sha }}'
#tags: 'ghcr.io/${{ github.repository_owner }}/solar-system:${{ github.sha }}'

dev-deploy:
needs: docker
runs-on: ubuntu-latest
environment:
name: development

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: "no"

- name: Install kubectl Cli
uses: azure/setup-kubectl@v3
with:
version: v1.26.0

- name: Set kubconfig file
uses: azure/k8s-set-context@v3
with:
method: kubeconfig
kubeconfig: '${{ secrets.KUBECONFIG }}'

- name: Fetch kubernetes cluster details
run: |
aws eks update-kubeconfig --name basic-cluster --region eu-north-1
kubectl version --short -o yaml
echo --------------------------
kubectl get nodes

- name: Save AWS Ingress Controller IP as a GITHUB Env variable
run: |
kubectl get ingress -n game-2048

- name: Replace Token in Manifest files
uses: cschleiden/replace-tokens@v1
with:
tokenPrefix: '_{_'
tokenSuffix: '_}_'
files: '["kubernetes/development/*.yaml"]'
env:
NAMESPACE: ${{ vars.NAMESPACE }}
REPLICAS: ${{ vars.REPLICAS }}
IMAGE: docker.io/seyiogunniran/solar-systems:${{ github.sha }}

- name: Check files list
run: cat kubernetes/development/*.yaml

# - name: Create MongoDB Seceret
# run: |
# kubectl -n ${{ vars.NAMESPACE }} create secret generic mongo-db-creds
# ---literal=MONGO_URI=${{ env.MONGO_URI }} \
# ---literal=MONGO_USERNAME=${{ env.MONGO_USERNAME }} \
# ---literal=MONGO_PASSWORD=${{ secrets.MONGO_PASSWORD }} \
# ---save-config \
# ---dry-run=client \
# -o yaml | kubectl apply -f -

- name: Deploy kubernetes
run: |
kubectl apply -f kubernetes/development




Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ spec:
tls:
- hosts:
- solar-system-_{_NAMESPACE_}_._{_INGRESS_IP_}_.nip.io
secretName: ingress-local-tls
secretName: ingress-local-tls
20 changes: 20 additions & 0 deletions kubernetes/development/ingressALB.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: solar
name: ingress-2048
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: solar-system
port:
number: 3000