ci: Use Netlify

This commit is contained in:
Thomas Schwery 2022-04-10 22:04:34 +02:00
parent 28d3116705
commit 184608d852
5 changed files with 19 additions and 49 deletions

5
.gitignore vendored
View file

@ -2,3 +2,8 @@
/public/
/resources/
# Local Netlify folder
.netlify
.hugo_build.lock
hugo

View file

@ -1,64 +1,32 @@
variables:
S3_BUCKET_NAME: recettes.inf3.ch
AWS_BUCKET_REGION: us-east-1
NETLIFY_SITE: recettes-4f3ee
HUGO_ENV: production
gohugo-build-branch:
image: monachus/hugo:v0.63.1
script:
- hugo -b http://${S3_BUCKET_NAME}.s3-website-${AWS_BUCKET_REGION}.amazonaws.com/${CI_COMMIT_REF_SLUG}
artifacts:
expire_in: 1 week
paths:
- public
except:
- /^master$/
gohugo-build-master:
image: monachus/hugo:v0.63.1
gohugo-build:
image: klakegg/hugo:0.95.0-debian
script:
- hugo
artifacts:
expire_in: 1 week
paths:
- public
only:
- /^master$/
deploys3-branch:
image: "python:latest"
deploy-branch:
image: "node:17"
stage: deploy
before_script:
- pip install awscli
- npm install -g netlify-cli --unsafe-perm=true
script:
- aws s3 cp public s3://${S3_BUCKET_NAME}/${CI_COMMIT_REF_SLUG} --recursive
environment:
name: ${CI_COMMIT_REF_SLUG}
url: http://${S3_BUCKET_NAME}.s3-website-${AWS_BUCKET_REGION}.amazonaws.com/${CI_COMMIT_REF_SLUG}
on_stop: deploys3-clean
- netlify deploy --site $NETLIFY_SITE --auth $NETLIFY_AUTH_TOKEN --dir public
except:
- /^master$/
deploys3-master:
image: "python:latest"
image: "node:17"
stage: deploy
before_script:
- pip install awscli
- npm install -g netlify-cli --unsafe-perm=true
script:
- aws s3 cp public s3://${S3_BUCKET_NAME}/ --recursive
environment:
name: ${CI_COMMIT_REF_SLUG}
url: http://${S3_BUCKET_NAME}.s3-website-${AWS_BUCKET_REGION}.amazonaws.com/
- netlify deploy --site $NETLIFY_SITE --auth $NETLIFY_AUTH_TOKEN --dir public --prod
only:
- /^master$/
deploys3-clean:
image: "python:latest"
stage: deploy
before_script:
- pip install awscli
script:
- aws s3 rm s3://${S3_BUCKET_NAME}/${CI_COMMIT_REF_SLUG} --recursive
environment:
name: ${CI_COMMIT_REF_SLUG}
action: stop
when: manual

View file

@ -2,7 +2,7 @@ contentDir = "content"
layoutDir = "layouts"
publishDir = "public"
buildDrafts = false
baseURL = "https://recettes.inf3.ch"
#baseURL = "https://recettes.inf3.ch"
canonifyURLs = true
theme = "hugo-recettes"

View file

@ -11,7 +11,7 @@
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}index.html</link>
<description>Les dernières recettes</description>
<generator>Hugo - {{ .Hugo.Version }} - gohugo.io</generator>{{ with .Site.LanguageCode }}
<generator>Hugo - {{ hugo.Version }} - gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}
{{ with .Site.LastChange }}

View file

@ -3,10 +3,7 @@
<ul class="list-group list-group-flush">
{{ with .Site.GetPage "/recettes" }}
{{ range sort .Sections ".Title" "asc"}}
{{ if eq $parentPage.File.UniqueID .File.UniqueID }}
{{ $active := "active" }}
{{ end }}
<a class="list-group-item d-flex justify-content-between list-group-item-action align-items-center $active" href="{{ .Permalink }}index.html">
<a class="list-group-item d-flex justify-content-between list-group-item-action align-items-center" href="{{ .Permalink }}index.html">
{{ .Title }}
<span class="badge badge-secondary badge-pill">{{ len .Pages }}</span>
</a>