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 branch #577

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0311044
Fix Dockerfile and package.json
Feb 28, 2024
7a3bac8
Workflow files
Mar 2, 2024
dcb7519
Fix outdated set-output command
Mar 2, 2024
d4c7878
Modify workflow to include k8s-related steps
Mar 2, 2024
36a46b0
Change path to K8s deployment files in workflow
Mar 2, 2024
5fd2f39
Add PAT to workflow
Mar 2, 2024
2bc0d07
Change PAT
Mar 2, 2024
be62611
Temp hello world message
Mar 2, 2024
892d140
Fix path
Mar 2, 2024
dd76648
Change path
Mar 2, 2024
ac3328e
Update Path
Mar 2, 2024
532c4c7
Change origin
Mar 2, 2024
4633757
Fix bash syntax
Mar 2, 2024
e134cf2
Remove ref
Mar 2, 2024
8a2bbbf
Fix bash syntax
Mar 2, 2024
9a22502
Fix deployment file path
Mar 2, 2024
7582da3
Add back docker commands
Mar 2, 2024
4bc239d
Comment out Docker commands, list dir.
Mar 2, 2024
96cd9e2
Debug
Mar 2, 2024
172f1fb
Debug
Mar 2, 2024
5d3c29e
Debug
Mar 2, 2024
664c5e8
Debug
Mar 2, 2024
75cad87
Debug
Mar 2, 2024
f9e9d49
Debug
Mar 2, 2024
30e5078
Debug
Mar 2, 2024
d17aa7f
Debug
Mar 2, 2024
22776ae
Debug
Mar 2, 2024
60edee3
Debug
Mar 2, 2024
c5fcf0b
Debug
Mar 2, 2024
ac8d3a4
Debug
Mar 2, 2024
a202e7f
Debug
Mar 2, 2024
729497f
Debug
Mar 2, 2024
2460808
update kube config
Mar 2, 2024
7a36ace
Debug
Mar 2, 2024
e930b54
Modify pipeline
Mar 5, 2024
810c915
Update pipeline with kubectl commands
Mar 5, 2024
2e8a533
Update gitignore
Mar 5, 2024
bcaadf4
Debug pipeline - kubectl
Mar 6, 2024
eee90e9
Update workflow
Mar 6, 2024
b9939bb
Update sed
Mar 6, 2024
9c3e6c3
Debug
Mar 6, 2024
8c7dc32
Debug sed
Mar 6, 2024
709fc4f
Debug sed
Mar 6, 2024
bde19d2
Debug
Mar 6, 2024
ea8ac4b
Debug
Mar 6, 2024
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
104 changes: 104 additions & 0 deletions .github/workflows/deploy-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Deploy Time Off app to EKS

on:
workflow_dispatch:
push:
branches:
- main

env:
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}

jobs:
build_and_push_image:
runs-on: ubuntu-latest

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

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

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Get short SHA
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
IMAGE_TAG: details-${{ env.sha }}
run: |
echo "Temp - Hello World"
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

- name: Checkout repo with K8s deployment files
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_MORNINGSTAR }}
repository: nrbs/morningstar-assignment
# path: k8s-manifests
ref: main
sparse-checkout: |
k8s-manifests
sparse-checkout-cone-mode: false

# - name: Debud - print current directory
# run: pwd

# - name: Debug - list directory contents
# run: ls -la

- name: Update Kubernetes deployment
env:
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
IMAGE_TAG: details-${{ env.sha }}
run: |
DEPLOYMENT_FILE="k8s-manifests/deployment.yaml"
sed -i "s|image: ECR_REGISTRY/ECR_REPOSITORY:IMAGE_TAG|image: ${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG}|" "$DEPLOYMENT_FILE"

# # Check if the deployment file needs to be updated
# if grep -q "image: ECR_REGISTRY/ECR_REPOSITORY:IMAGE_TAG" "$DEPLOYMENT_FILE"; then
# echo "Image is already up to date in $DEPLOYMENT_FILE"
# else
# # Update image tag in deployment file
# sed -i "s|image: ECR_REGISTRY/ECR_REPOSITORY:IMAGE_TAG|image: ${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG}|" "$DEPLOYMENT_FILE"

# # Show updated deployment file
# echo "---------------------------------------------------------------------"
# cat "$DEPLOYMENT_FILE"
# fi

- name: Update kube-config
run: |
aws eks update-kubeconfig --name timeoff-app --region us-east-1

- name: Deploy to EKS
run: |
cd k8s-manifests
echo "Current directory: $PWD"
echo "---------------------------------------------------------------------"
echo "Namespaces:"
kubectl get namespaces
echo "---------------------------------------------------------------------"
kubectl config set-context --current --namespace=timeoff-app
echo "Current namespace: $(kubectl config view --minify --output 'jsonpath={..namespace}')"
kubectl apply -f deployment.yaml
kubectl apply -f nginx-ingress.yaml
echo "---------------------------------------------------------------------"
kubectl config set-context --current --namespace=cert-manager
echo "Current namespace: $(kubectl config view --minify --output 'jsonpath={..namespace}')"
kubectl apply -f cert-manager.yaml


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
*.swm
node_modules/
*.sqlite
.DS_Store
.vscode/
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,26 @@
FROM alpine:latest as dependencies

RUN apk add --no-cache \
nodejs npm
nodejs npm \
python3 \
make \
build-base

COPY package.json .
RUN npm install
RUN npm install

# --------------------------------------------------------------------
FROM alpine:latest

LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.docker.cmd="docker run -d -p 3000:3000 --name alpine_timeoff"

RUN apk add --no-cache \
nodejs npm \
vim
vim \
python3 \
make \
build-base

RUN adduser --system app --home /app
USER app
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"devDependencies": {
"chai": "^2.2.0",
"mocha": "^6.2.2",
"node-sass": "^4.5.3",
"sass": "^1.43.5",
"request-promise": "^4.2.2",
"selenium-webdriver": "2.53.3"
},
Expand Down