106 lines
3.1 KiB
YAML
106 lines
3.1 KiB
YAML
name: Website
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- main
|
|
paths:
|
|
- 'website/**'
|
|
- 'assets/**'
|
|
pull_request:
|
|
types: [opened, synchronize, ready_for_review, reopened]
|
|
paths:
|
|
- 'website/**'
|
|
- 'assets/**'
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: "website"
|
|
cancel-in-progress: false
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
update-date:
|
|
name: Auto update dates
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request' || (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
|
|
steps:
|
|
- uses: DeterminateSystems/nix-installer-action@v10
|
|
with:
|
|
diagnostic-endpoint: ""
|
|
- uses: DeterminateSystems/magic-nix-cache-action@v4
|
|
with:
|
|
diagnostic-endpoint: ""
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Check for changes
|
|
run: |
|
|
IS_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -Ec "^website*" || :)
|
|
[[ $IS_CHANGED -gt 0 ]] && echo "IS_CHANGED=true" >> $GITHUB_ENV || echo "IS_CHANGED=false" >> $GITHUB_ENV
|
|
|
|
- name: Update last modified date in modified docs
|
|
if: env.IS_CHANGED == 'true'
|
|
run: |
|
|
git diff --name-only --diff-filter=d ${{ github.event.before }} ${{ github.sha }} | grep -E "^website*" \
|
|
| sed -e 's/\(.*\)/"\1"/' | xargs sed -i "/date:/c\date: $(date +'%Y-%m-%d')"
|
|
|
|
- name: Create Pull Request
|
|
uses: peter-evans/create-pull-request@v6
|
|
if: env.IS_CHANGED == 'true' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
|
|
with:
|
|
commit-message: Auto-updated docs
|
|
branch: docs-generator
|
|
title: Auto-generated docs update
|
|
body: |
|
|
Auto generated docs from master commit ${{ github.sha }}
|
|
|
|
website-generate:
|
|
name: Auto generate website
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request' || (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
|
|
steps:
|
|
- uses: DeterminateSystems/nix-installer-action@v10
|
|
with:
|
|
diagnostic-endpoint: ""
|
|
- uses: DeterminateSystems/magic-nix-cache-action@v4
|
|
with:
|
|
diagnostic-endpoint: ""
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
- name: nix checks
|
|
run: nix flake check
|
|
- name: nix build
|
|
env:
|
|
HUGO_ENVIRONMENT: production
|
|
HUGO_ENV: production
|
|
run: nix build .#website
|
|
- name: Setup Pages
|
|
id: pages
|
|
uses: actions/configure-pages@v5
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: ./result
|
|
|
|
website-deploy:
|
|
name: Deploy website
|
|
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
needs: website-generate
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|