Skip to content

Commit

Permalink
ci: generate a static site with Hugo
Browse files Browse the repository at this point in the history
Signed-off-by: knqyf263 <[email protected]>
  • Loading branch information
knqyf263 committed May 6, 2024
1 parent a1c7fa3 commit c2c494c
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 7 deletions.
42 changes: 35 additions & 7 deletions .github/workflows/deploy-index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,46 @@ on:
branches: [ "main" ]
workflow_dispatch:

# Default to bash
defaults:
run:
shell: bash

jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.125.6
steps:
- uses: actions/checkout@v4
- run: |
mkdir -p data/v1
cat plugins/*.yaml > data/v1/index.yaml
- uses: actions/upload-pages-artifact@v1
- name: Generate a list of plugins
run: |
mkdir -p site/data/v1
cat plugins/*.yaml > site/data/v1/plugins.yaml
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
-s site \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- uses: actions/upload-pages-artifact@v3
with:
path: data

path: site/public
deploy:
needs: build
name: Deploy
Expand All @@ -29,5 +56,6 @@ jobs:
pages: write
id-token: write
steps:
- uses: actions/deploy-pages@v1
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
id: deployment
Empty file added site/.hugo_build.lock
Empty file.
5 changes: 5 additions & 0 deletions site/archetypes/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
date = {{ .Date }}
draft = true
+++
10 changes: 10 additions & 0 deletions site/hugo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
baseURL: "/"
languageCode: en-us
title: Trivy Plugins
enableGitInfo: true
enableRobotsTXT: true
canonifyURLs: true

disableKinds:
- taxonomy

11 changes: 11 additions & 0 deletions site/layouts/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ define "main" }}

<h1 class="display-3 text-danger">Not found</h1>

<p class="lead">
Sorry, this URL cannot be found. Maybe it’s moved.
</p>

<a href=" {{ "/" }} " class="btn btn-lg btn-primary">&larr; Home</a>

{{ end }}
28 changes: 28 additions & 0 deletions site/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ .Site.Title }}</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/style.css">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<style>
.stars {
display: inline-block;
vertical-align: middle;
margin-left: 10px;
}
</style>
</head>

{{ partial "header.html" . }}

<body>
<main>
{{ block "main" . }}{{ end }}
</main>
</body>
</html>

41 changes: 41 additions & 0 deletions site/layouts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{ define "main" }}
<body>
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<h1>{{ .Site.Title }}</h1>
<p>Below you will find the list of Trivy plugins distributed on the centralized
<a href="https://github.com/aquasecurity/trivy-plugin-index">trivy-plugin-index</a>. To install these plugins on your machine:</p>
<ol>
<li><a href="https://aquasecurity.github.io/trivy/v0.51/getting-started/installation/">Install the latest version of Trivy</a></li>
<li>Run <code>trivy plugin install &lt;PLUGIN_NAME&gt;</code> to install a plugin.</li>
</ol>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Repository</th>
</tr>
</thead>
<tbody>
{{ range .Site.Data.v1.plugins }}
<tr>
<td><a href="{{ .repo }}" target="_blank">{{ .name }}</a></td>
<td>{{ if .type }}{{ .type }}{{ else }}generic{{ end }}</td>
<td>{{ .summary }}</td>
<td>
<a href="{{ .repo }}" target="_blank">
<img src="https://img.shields.io/github/stars/{{ replace .repo "https://github.com/" "" }}?style=social" alt="GitHub stars">
</a>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
</div>
</body>
{{ end }}
10 changes: 10 additions & 0 deletions site/layouts/partials/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<header class="header">
<div class="container container-header">
<div class="logo">
<a href="/" class="header-logo">
<img src="/img/trivy-logo.svg" alt="Trivy Logo" style="height: 70px;">
</a>
</div>
</div>
</header>

17 changes: 17 additions & 0 deletions site/static/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.header {
background-color: #f8f9fa;
padding: 10px 0;
margin: 0;
margin-bottom: 30px;
}

.logo {
display: flex;
align-items: center;
justify-content: flex-start;
}

.header-logo {
margin-top: -10px;
margin-left: 120px;
}
85 changes: 85 additions & 0 deletions site/static/img/trivy-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c2c494c

Please sign in to comment.