Skip to content

test: verify automatic release workflow (#230) #105

test: verify automatic release workflow (#230)

test: verify automatic release workflow (#230) #105

Workflow file for this run

name: Push
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
on:
push:
branches:
- conda
- main
paths:
- "projects/**"
- "cli/**"
- ".github/**"
jobs:
build-docs:
name: Build Main Documentation
uses: ./.github/workflows/build-docs-optimized.yml
with:
environment_name: ${{ github.ref_name }}
deployment_type: push
permissions:
contents: read
pages: write
id-token: write
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
needs: build-docs
environment:
name: ${{ github.ref_name }}
url: ${{ needs.build-docs.outputs.deploy-url }}
defaults:
run:
shell: bash -el {0}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Upgrade conda
run: |
conda update -n base -c conda-forge conda -y -q
conda --version
shell: bash
- name: Setup Conda (for deployment)
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: false
python-version: "3.13"
channels: conda-forge,defaults
channel-priority: true
environment-file: environment.yml
activate-environment: edbook
use-mamba: true
- name: Build for production deployment
run: |
# Use the optimized build for production
mkdir -p _build
cd projects
# Build projects in parallel with optimizations
project_list=""
for project in */; do
if [ -d "$project" ] && [ -f "$project/conf.py" ]; then
project_name=${project%/}
project_list="$project_list $project_name"
# Pre-create hover terms file
if [ ! -f "$project/LIST_OF_HOVER_TERMS.json" ]; then
echo "[]" > "$project/LIST_OF_HOVER_TERMS.json"
fi
fi
done
# Use xargs for parallel builds (more reliable than GNU parallel)
echo "$project_list" | tr ' ' '\n' | xargs -n1 -P4 -I{} bash -c '
project="{}"
echo "Building $project for production..."
cd "$project"
sphinx-build -b html -j auto -q --keep-going \
-D html_show_sourcelink=0 \
-D html_copy_source=0 \
. "../../_build/$project" || echo "Build failed for $project, continuing..."
'
cd ..
# Move forsida to root for production
if [ -d "_build/forsida" ]; then
echo "Moving forsida to root for production"
cp -r _build/forsida/* _build/
rm -rf _build/forsida
fi
- name: Checkout edbook.github.io
uses: actions/checkout@v4
with:
repository: 'edbook/edbook.github.io'
path: org-repo
ssh-key: ${{ secrets.SSH_DEPLOY_KEY }}
- name: Push to edbook.github.io
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
VERSION: ${{ needs.build-docs.outputs.version }}
run: |
# Sync build to production repository (exclude .git to preserve checkout credentials)
rsync -avh --delete --exclude='.git' _build/ ./org-repo/
cd org-repo
# Configure git
git config user.name github-actions
git config user.email github-actions@github.com
# Commit and push
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "$COMMIT_MSG" -m "Version: $VERSION" -m "https://github.com/${{ github.repository }}/commit/$GITHUB_SHA"
git push
echo "Successfully deployed to production"
fi
notify-discord-push:
needs: [build-docs, deploy-production]
name: Notify Discord (push to main)
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Notify push
env:
CONTENT_TITLE: "Ný útgáfa er kominn í loftið 🎉"
TITLE: "Push to ${{ github.ref_name }}"
COLOR: "32768"
DESCRIPTION: ${{ github.event.head_commit.message }}
URL: "https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
AUTHOR_NAME: ${{ github.event.head_commit.author.name }}
AUTHOR_USERNAME: ${{ github.event.head_commit.author.username }}
VERSION: ${{ needs.build-docs.outputs.version }}
run: |
payload="$(jq -n \
--arg ct "$CONTENT_TITLE" \
--arg title "$TITLE" \
--arg desc "$DESCRIPTION" \
--arg url "$URL" \
--arg author_name "$AUTHOR_NAME" \
--arg author_url "https://github.com/${AUTHOR_USERNAME}" \
--arg author_avatar "https://github.com/${AUTHOR_USERNAME}.png" \
--arg version "$VERSION" \
--arg edbook_url "https://edbook.hi.is" \
--argjson color "$COLOR" \
'{
content: $ct,
avatar_url: "https://www.shareicon.net/data/128x128/2015/08/28/92005_social-media_512x512.png",
embeds: [
{
title: $title,
description: $desc,
url: $url,
color: $color,
fields: [
{ name: "Version", value: $version },
{ name: "url", value: ("[Skoða á edbook](" + $edbook_url + ")") }
],
author: { name: $author_name, url: $author_url, icon_url: $author_avatar }
}
]
}')"
./.github/discord.sh \
-w "${{ secrets.DISCORD_WEBHOOK }}" \
-c "$payload"
notify-discord-build-failed:
needs: [build-docs, deploy-production]
if: always() && (needs.build-docs.result == 'failure' || needs.deploy-production.result == 'failure') && github.event_name == 'push'
name: Notify Discord (build failed)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Notify build or deploy failed
env:
CONTENT_TITLE: "Eitthvað fór úrskeiðis ☠️"
REF_NAME: ${{ github.ref_name }}
COLOR: "16711680"
AUTHOR_NAME: ${{ github.event.sender.login }}
AUTHOR_URL: ${{ github.event.sender.html_url }}
AUTHOR_AVATAR: ${{ github.event.sender.avatar_url }}
run: |
workflow_url="https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
payload="$(jq -n \
--arg ct "$CONTENT_TITLE" \
--arg title "$REF_NAME" \
--arg desc "Ekki tókst að byggja og/eða deploya branchinu _${REF_NAME}_" \
--arg url "$workflow_url" \
--arg author_name "$AUTHOR_NAME" \
--arg author_url "$AUTHOR_URL" \
--arg author_avatar "$AUTHOR_AVATAR" \
--argjson color "$COLOR" \
'{
content: $ct,
avatar_url: "https://www.shareicon.net/data/128x128/2015/08/28/92005_social-media_512x512.png",
embeds: [
{
title: $title,
description: $desc,
url: $url,
color: $color,
author: { name: $author_name, url: $author_url, icon_url: $author_avatar }
}
]
}')"
./.github/discord.sh \
-w "${{ secrets.DISCORD_WEBHOOK }}" \
-c "$payload"