Skip to content

rewrite readme

rewrite readme #6

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master ]
env:
RUBY_VERSION: '3.2.0'
BUNDLE_PATH: vendor/bundle
jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
services:
prometheus:
image: prom/prometheus:latest
ports:
- 9090:9090
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Install dependencies
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Run RuboCop
run: bundle exec rubocop
- name: Run RSpec tests
run: bundle exec rspec --format documentation
- name: Upload coverage reports
uses: codecov/codecov-action@v3
if: success()
with:
file: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Run security audit
run: |
bundle audit --update
bundle exec brakeman --no-pager
build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [test, security]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: quay.io/dkirwan/asset_monitoring
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy to Kubernetes
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure kubectl
uses: azure/k8s-set-context@v3
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- name: Deploy to Kubernetes
run: |
# Update image tag in deployment
sed -i "s|quay.io/dkirwan/asset_monitoring:.*|quay.io/dkirwan/asset_monitoring:${GITHUB_SHA}|g" kubernetes/deployment.yaml
# Apply Kubernetes manifests
kubectl apply -f kubernetes/
# Wait for deployment to be ready
kubectl rollout status deployment/crypto -n monitoring-example --timeout=300s