From 8f65215006ba92ef626dc75415d140609782c79b Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Sat, 17 Aug 2024 11:50:17 +0200 Subject: [PATCH] feat: add initial Hugo site and CI configuration Signed-off-by: Roald Nefs --- .github/workflows/publish.yml | 37 +++++++++++++++++++++++++++++++++++ .gitignore | 8 ++++++++ archetypes/default.md | 5 +++++ hugo.toml | 3 +++ publish.sh | 30 ++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100644 .gitignore create mode 100644 archetypes/default.md create mode 100644 hugo.toml create mode 100644 publish.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..807d05f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +name: Publish + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Configure Git for GitHub + run: | + git config --global user.name "Roald Nefs" + git config --global user.email "roaldnefs@users.noreply.github.com" + + - uses: actions/checkout@v2 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token + fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + submodules: true + + - name: Set up Hugo + env: + HUGO_VERSION: 0.112.0 + run: | + echo "installing hugo $HUGO_VERSION" + curl -sL -o /tmp/hugo.deb \ + https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.deb && \ + sudo dpkg -i /tmp/hugo.deb && \ + rm /tmp/hugo.deb + + - name: Publish + env: + REPOSITORY: "https://roaldnefs:${{ secrets.GITHUB_TOKEN }}@github.com/bsidesgrunn/bsidesgrunn.org.git" + run: ./publish.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10ad007 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +public/ +resources/_gen/ +.hugo_build.lock + +node_modules/ +package-lock.json + +.DS_Store \ No newline at end of file diff --git a/archetypes/default.md b/archetypes/default.md new file mode 100644 index 0000000..c6f3fce --- /dev/null +++ b/archetypes/default.md @@ -0,0 +1,5 @@ ++++ +title = '{{ replace .File.ContentBaseName "-" " " | title }}' +date = {{ .Date }} +draft = true ++++ diff --git a/hugo.toml b/hugo.toml new file mode 100644 index 0000000..4574c88 --- /dev/null +++ b/hugo.toml @@ -0,0 +1,3 @@ +baseURL = 'https://bsidesgrunn.org/' +languageCode = 'en-us' +title = 'BSides Groningen' diff --git a/publish.sh b/publish.sh new file mode 100644 index 0000000..b064f3f --- /dev/null +++ b/publish.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +if [ "`git status -s`" ] +then + echo "[-] The working directory is dirty. Please commit any pending changes." + exit 1; +fi + +echo "[+] Deleting old publication." +rm -rf public +mkdir public +git worktree prune +rm -rf .git/worktrees/public/ + +echo "[+] Checking out gh-pages branch into public." +git worktree add -B gh-pages public origin/gh-pages + +echo "[+] Removing existing files." +rm -rf public/* + +echo "[+] Generating site." +hugo + +echo "[+] Updating gh-pages branch." +cd public && git add --all && git commit -m "chore: publishing to gh-pages (publish.sh)" + +echo "[+] Pushing to GitHub." +git push -f ${REPOSITORY:-origin} gh-pages + +echo "[+] Updates have been published."