Skip to content

Commit 7dabb47

Browse files
committed
✨ Initial Commit
1 parent afec888 commit 7dabb47

40 files changed

+5679
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Deploy Container to GHCR
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
paths:
7+
- 'src/**'
8+
- 'Dockerfile'
9+
- 'package.json'
10+
- 'package-lock.json'
11+
pull_request:
12+
branches: [ main ]
13+
paths:
14+
- 'src/**'
15+
- 'Dockerfile'
16+
- 'package.json'
17+
- 'package-lock.json'
18+
release:
19+
types: [ published ]
20+
21+
env:
22+
REGISTRY: ghcr.io
23+
IMAGE_NAME: ${{ github.repository }}
24+
25+
jobs:
26+
build-and-push:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
30+
packages: write
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Log in to Container Registry
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Extract metadata
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
tags: |
52+
type=ref,event=branch
53+
type=ref,event=pr
54+
type=sha,prefix={{branch}}-
55+
type=raw,value=latest,enable={{is_default_branch}}
56+
type=semver,pattern={{version}}
57+
type=semver,pattern={{major}}.{{minor}}
58+
59+
- name: Build and push Docker image
60+
id: build
61+
uses: docker/build-push-action@v5
62+
with:
63+
context: .
64+
push: true
65+
tags: ${{ steps.meta.outputs.tags }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max
69+
70+
- name: Output image digest
71+
run: 'echo "Image digest: ${{ steps.build.outputs.digest }}"'
72+
73+
test:
74+
runs-on: ubuntu-latest
75+
needs: build-and-push
76+
if: github.event_name == 'pull_request'
77+
78+
steps:
79+
- name: Checkout repository
80+
uses: actions/checkout@v4
81+
82+
- name: Set up Node.js
83+
uses: actions/setup-node@v4
84+
with:
85+
node-version: '18'
86+
cache: 'npm'
87+
88+
- name: Install dependencies
89+
run: npm ci
90+
91+
- name: Run tests
92+
run: npm test
93+
94+
security-scan:
95+
runs-on: ubuntu-latest
96+
needs: build-and-push
97+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
98+
99+
steps:
100+
- name: Checkout repository
101+
uses: actions/checkout@v4
102+
103+
- name: Run Trivy vulnerability scanner
104+
uses: aquasecurity/trivy-action@master
105+
with:
106+
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
107+
format: 'sarif'
108+
output: 'trivy-results.sarif'
109+
110+
- name: Upload Trivy scan results to GitHub Security tab
111+
uses: github/codeql-action/upload-sarif@v3
112+
if: always()
113+
with:
114+
sarif_file: 'trivy-results.sarif'

.github/workflows/publish-helm.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'helm/**'
9+
- '.github/workflows/publish-helm.yml'
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Configure Git
24+
run: |
25+
git config user.name "$GITHUB_ACTOR"
26+
git config user.email "[email protected]"
27+
28+
- name: Run chart-releaser
29+
uses: helm/[email protected]
30+
env:
31+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
32+
with:
33+
charts_dir: helm

.github/workflows/setup-pages.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Setup GitHub Pages
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
pages: write
8+
id-token: write
9+
10+
concurrency:
11+
group: "pages"
12+
cancel-in-progress: false
13+
14+
jobs:
15+
setup:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Setup Pages
19+
uses: actions/configure-pages@v4
20+
21+
- name: Create index.html
22+
run: |
23+
mkdir -p dist
24+
echo '<!DOCTYPE html>' > dist/index.html
25+
echo '<html>' >> dist/index.html
26+
echo '<head>' >> dist/index.html
27+
echo ' <title>Slaking Helm Repository</title>' >> dist/index.html
28+
echo ' <meta charset="utf-8">' >> dist/index.html
29+
echo ' <meta name="viewport" content="width=device-width, initial-scale=1">' >> dist/index.html
30+
echo ' <style>' >> dist/index.html
31+
echo ' body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; margin: 40px; }' >> dist/index.html
32+
echo ' .container { max-width: 800px; margin: 0 auto; }' >> dist/index.html
33+
echo ' h1 { color: #24292e; }' >> dist/index.html
34+
echo ' .repo-info { background: #f6f8fa; padding: 20px; border-radius: 6px; margin: 20px 0; }' >> dist/index.html
35+
echo ' .install { background: #dafbe1; padding: 20px; border-radius: 6px; margin: 20px 0; }' >> dist/index.html
36+
echo ' code { background: #f6f8fa; padding: 2px 6px; border-radius: 3px; }' >> dist/index.html
37+
echo ' pre { background: #f6f8fa; padding: 15px; border-radius: 6px; overflow-x: auto; }' >> dist/index.html
38+
echo ' </style>' >> dist/index.html
39+
echo '</head>' >> dist/index.html
40+
echo '<body>' >> dist/index.html
41+
echo ' <div class="container">' >> dist/index.html
42+
echo ' <h1>🚀 Slaking Helm Repository</h1>' >> dist/index.html
43+
echo ' <div class="repo-info">' >> dist/index.html
44+
echo ' <h2>About</h2>' >> dist/index.html
45+
echo ' <p>This is the Helm chart repository for Slaking, a Kubernetes service that monitors workloads for annotations and sends filtered logs to Slack channels.</p>' >> dist/index.html
46+
echo ' </div>' >> dist/index.html
47+
echo ' <div class="install">' >> dist/index.html
48+
echo ' <h2>Installation</h2>' >> dist/index.html
49+
echo ' <p>Add this repository to your Helm installation:</p>' >> dist/index.html
50+
echo ' <pre><code>helm repo add slaking https://REPO_OWNER.github.io/REPO_NAME' >> dist/index.html
51+
echo 'helm repo update</code></pre>' >> dist/index.html
52+
echo ' <p>Install the Slaking chart:</p>' >> dist/index.html
53+
echo ' <pre><code>helm install slaking slaking/slaking</code></pre>' >> dist/index.html
54+
echo ' </div>' >> dist/index.html
55+
echo ' <div class="repo-info">' >> dist/index.html
56+
echo ' <h2>Documentation</h2>' >> dist/index.html
57+
echo ' <p>For more information, visit the <a href="https://github.com/REPO_FULL">GitHub repository</a>.</p>' >> dist/index.html
58+
echo ' </div>' >> dist/index.html
59+
echo ' </div>' >> dist/index.html
60+
echo '</body>' >> dist/index.html
61+
echo '</html>' >> dist/index.html
62+
63+
- name: Replace placeholders
64+
run: |
65+
sed -i "s/REPO_OWNER/${{ github.repository_owner }}/g" dist/index.html
66+
sed -i "s/REPO_NAME/${{ github.event.repository.name }}/g" dist/index.html
67+
sed -i "s|REPO_FULL|${{ github.repository }}|g" dist/index.html
68+
69+
- name: Upload artifact
70+
uses: actions/upload-pages-artifact@v3
71+
with:
72+
path: ./dist
73+
74+
deploy:
75+
environment:
76+
name: github-pages
77+
url: ${{ steps.deployment.outputs.page_url }}
78+
runs-on: ubuntu-latest
79+
needs: setup
80+
steps:
81+
- name: Deploy to GitHub Pages
82+
id: deployment
83+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)