Skip to content

Gh actions for docs (#805) #500

Gh actions for docs (#805)

Gh actions for docs (#805) #500

Workflow file for this run

name: Release
on:
push:
tags:
- "*-?v[0-9]+*"
env:
REGISTRY: ghcr.io
permissions:
contents: write
packages: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create or update release
uses: actions/github-script@v7
env:
TAG_NAME: ${{ github.ref_name }}
with:
script: |
const tag = process.env.TAG_NAME || github.ref_name;
const repo = context.repo;
const majorVersion = tag.match(/v(\d+)\.\d+\.\d+/)[1];
const releaseName = `Version ${majorVersion}`;
const date = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
const dynamicBody = `<!-- DYNAMIC START -->\n*Created from tag*: \`${tag}\`\n*Created from git revision*: \`${context.sha}\`\n*Published on*: \`${date}\`\n<!-- DYNAMIC END -->`;
async function findOrCreateRelease() {
const { data: releases } = await github.rest.repos.listReleases(repo);
let existingRelease = releases.find(release => release.name === releaseName);
if (existingRelease) {
const existingBody = existingRelease.body;
const newBody = existingBody.replace(/<!-- DYNAMIC START -->[^]*<!-- DYNAMIC END -->/, dynamicBody);
await github.rest.repos.updateRelease({
...repo,
release_id: existingRelease.id,
tag_name: tag,
body: newBody
});
console.log("Release updated to associate with new tag.");
} else {
const fullBody = `${dynamicBody}\n\n## Release Notes\n\n- Some bug fixes.`;
await github.rest.repos.createRelease({
...repo,
tag_name: tag,
name: releaseName,
body: fullBody,
draft: false,
prerelease: false
});
console.log("Release created successfully.");
}
}
findOrCreateRelease();
docker-release:
runs-on: ubuntu-latest
needs: create-release
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get docker image name and build args
id: required_args
run: |
image_name="${{ env.REGISTRY }}/${{ github.actor }}/${{ github.event.repository.name }}"
image_names="$image_name:${{ github.ref_name }},$image_name:latest"
# lowercase the name
image_names=$(echo "$image_names" | tr '[:upper:]' '[:lower:]')
echo "image_names=$image_names" >> $GITHUB_OUTPUT
- name: Build and push to ghcr
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.required_args.outputs.image_names }}
upload-kodi-plugin:
runs-on: ubuntu-20.04
needs: docker-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Setup Moon
uses: moonrepo/setup-toolchain@v0
with:
auto-install: true
- name: Build plugin
run: moon run kodi:build
- name: Upload plugin to releases
run: gh release upload --clobber ${{ github.ref_name }} "tmp/script.ryot.zip"
deploy-demo-instance:
runs-on: ubuntu-latest
needs: docker-release
steps:
- uses: actions/checkout@v4
- name: Set up CLI
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy
run: flyctl deploy --remote-only --detach --config ci/fly.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
deploy-docs:
runs-on: ubuntu-latest
needs: docker-release
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Install dependencies
run: cd docs && poetry install
- name: Build docs
run: cd docs && poetry run mkdocs build
- name: Push to deployment branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/site
publish_branch: nf-docs
force_orphan: true
deploy-landing:
runs-on: ubuntu-latest
needs: docker-release
steps:
- uses: actions/checkout@v4
- name: Setup Moon
uses: moonrepo/setup-toolchain@v0
with:
auto-install: true
- name: Build landing page
run: moon run landing:build
- name: Push to deployment branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: apps/landing/dist
publish_branch: nf-landing
force_orphan: true