Skip to content

Merge pull request #53 from SeiferTim/main #291

Merge pull request #53 from SeiferTim/main

Merge pull request #53 from SeiferTim/main #291

Workflow file for this run

name: ⚙ Build the Hugo Site
on:
workflow_dispatch:
workflow_call:
inputs:
triggeredByEventChange:
required: true
type: boolean
push:
branches:
- main
tags-ignore:
- generated.**
paths-ignore:
- '.github/**'
permissions: write-all
concurrency:
group: "pages"
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
check-repo:
runs-on: ubuntu-latest
outputs:
is-official: ${{ steps.set.outputs.is-official }}
steps:
- name: Check if running on stlgamedev/STLGameDevSite
id: set
run: |
if [[ "${GITHUB_REPOSITORY}" == "stlgamedev/STLGameDevSite" ]]; then
echo "Running in official repo."
echo "is-official=true" >> $GITHUB_OUTPUT
else
echo "⚠️ This workflow runs only on the main stlgamedev/STLGameDevSite repo. Skipping..."
echo "is-official=false" >> $GITHUB_OUTPUT
fi
build:
needs: check-repo
if: needs.check-repo.outputs.is-official == 'true'
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.147.2
outputs:
base_url: ${{ steps.pages.outputs.base_url }}
new_news_items: ${{ steps.compare-new-news.outputs.new_items }}
steps:
# - name: check existing news
# id: check-news
# run: |
# curl -s https://stlgame.dev/news/index.json -o news_index.json
# old_news=$(jq . news_index.json)
# echo 'old_news'=$old_news >> $GITHUB_OUTPUT
- 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: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.10.0
- name: Install dependencies
run: npm ci
- name: Pull
run: git pull
- name: Build
env:
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
HUGO_ENVIRONMENT: production
HUGO_ENV: production
TZ: America/Chicago
run: |
hugo \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
# - name: compare new news
# id: compare-new-news
# run: |
# new_news=$(echo $(cat ./public/news/index.json))
# new_news=$(echo $new_news | jq)
# old_news='${{ steps.check-news.outputs.old_news }}'
# new_items=$(jq -r -n --argjson old "$old_news" --argjson new "$new_news" '$new - $old')
# echo $new_items
# echo new_items=$new_items >> $GITHUB_OUTPUT
- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public
deploy:
needs: [build, check-repo]
if: needs.check-repo.outputs.is-official == 'true'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
outputs:
base_url: ${{ needs.build.outputs.base_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
# share:
# runs-on: ubuntu-latest
# needs: build
# if: needs.build.outputs.new_news_items != '[]'
# strategy:
# matrix:
# steps: ${{ fromJSON( needs.build.outputs.new_news_items ) }}
# steps:
# - name: get new one
# id: get-new-one
# run: |
# new_one='${{ toJSON(matrix.steps) }}'
# embeds=$(echo $new_one | jq -r ' . | { "title": .title, "url": .url }')
# embeds=$(echo $embeds | jq -c '[ . ]')
# echo 'embeds'=$embeds >> $GITHUB_OUTPUT
# - name: discord post
# id: discord-post
# uses: Ilshidur/action-discord@master
# env:
# DISCORD_USERNAME: "STLGameDev"
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# DISCORD_EMBEDS: ${{ steps.get-new-one.outputs.embeds }}
# with:
# args: ":newspaper: A News Article has been posted on the website!"
# - name: Tweet
# id: tweet
# uses: dart-actions/[email protected]
# with:
# consumer-key: ${{ secrets.TWITTER_CONSUMER_KEY }}
# consumer-secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
# access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
# access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
# text: |
# 📰 A new post has been created!
# ${{ steps.get-new-one.outputs.embeds.title }}
# ${{ steps.get-new-one.outputs.embeds.url }}
# #STL #GameDev
# - name: Bsky
# uses: myConsciousness/bluesky-post@v5
# with:
# text: |
# 📰 A new post has been created!
# ${{ steps.get-new-one.outputs.embeds.title }}
# ${{ steps.get-new-one.outputs.embeds.url }}
# #STL #GameDev
# link-preview-url: ${{ steps.get-new-one.outputs.embeds.url }}
# identifier: "stlgame.dev"
# password: ${{ secrets.BLUESKY_PASSWORD }}