Skip to content

Commit

Permalink
feat: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
carlohcs committed Aug 3, 2024
0 parents commit abef200
Show file tree
Hide file tree
Showing 16 changed files with 6,765 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy to EKS
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Update kube config
run: aws eks update-kubeconfig --name carlohcs-k8s-cluster --region us-east-1

- name: Login to DockerHub
run: docker login -u carlohcs -p ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
run: |
docker build -t carlohcs/kubernetes-ci-cd-github-actions .
docker push carlohcs/kubernetes-ci-cd-github-actions
- name: Deploy to EKS
run: |
kubectl apply -f k8s/node-deployment.yaml
kubectl apply -f k8s/node-service.yaml
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

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

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install dependencies
run: npm install

# - name: Run tests
# run: npm test

# - name: Check test status
# run: echo "::set-output name=test_failed::$(grep -q 'Test Suites:.*failed' ./test-results.txt && echo true || echo false)"

# - name: Stop on test failure
# if: ${{ steps.check_test_status.outputs.test_failed == 'true' }}
# run: exit 1
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# build output
dist/

# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# jetbrains setting folder
.idea/
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 22.0.0
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM --platform=linux/amd64 node:22.0.0

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

EXPOSE 3000

CMD [ "npm", "run", "server" ]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Kubernetes with CI/CD and GitHub Actions

This project is a comprehensive guide to implementing CI/CD pipelines for Kubernetes using GitHub Actions.

It covers everything from setting up a Kubernetes cluster to automating the deployment process with GitHub Actions.

Whether you're new to Kubernetes or looking to enhance your existing CI/CD workflows, this guide provides step-by-step instructions and best practices to streamline your development process.

With the power of GitHub Actions, you can easily automate the building, testing, and deployment of your Kubernetes applications, ensuring faster and more reliable releases.

Get started today and take your CI/CD to the next level with Kubernetes and GitHub Actions.

## Build the image

```bash
docker build . -t carlohcs/kubernetes-ci-cd-github-actions:1
```

## Run the application

```bash
docker run -p 3000:3000 carlohcs/kubernetes-ci-cd-github-actions:1
```
4 changes: 4 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({});
Loading

0 comments on commit abef200

Please sign in to comment.