Skip to content

Build and Deploy

Build and Deploy #316

Workflow file for this run

on:
workflow_dispatch:
push:
branches:
- main
# Refresh to add new IFS images/albums
schedule:
- cron: '0 6 * * *' # 6:00 daily
name: Build and Deploy
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'checkout'
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- run: pip install -r requirements.txt
- run: python albums.py
- run: python ifs.py
- name: Set base-url (main)
shell: bash
if: github.ref == 'refs/heads/main'
run: echo "TARGET_URL=https://www.mainframe.io" >> $GITHUB_ENV
- name: Set base-url (PR)
shell: bash
if: github.ref != 'refs/heads/main'
run: echo "TARGET_URL=https://www.mainframe.io/www/${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
- name: 'build'
uses: shalzz/zola-deploy-action@v0.21.0
env:
BUILD_ONLY: true
BUILD_DIR: .
BUILD_FLAGS: "--base-url ${{ env.TARGET_URL }}"
TOKEN: ${{ secrets.TOKEN }}
- name: 'upload artifact'
uses: actions/upload-artifact@v4
with:
path: 'public/'
if-no-files-found: error
retention-days: 7
name: website
deployment:
runs-on: ubuntu-latest
needs: build
steps:
- name: 'checkout'
uses: actions/download-artifact@v5
with:
name: website
path: public/
- name: 'Extract branch name'
shell: bash
run: echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
id: extract_branch
- name: 'deploy (Staging)'
if: github.ref != 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.TOKEN }}
destination_dir: ${{ env.BRANCH }}
- name: 'deploy (prod)'
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.TOKEN }}
destination_dir: ./
external_repository: ktt-ol/ktt-ol.github.io
publish_branch: master