Skip to content

Improved documentation and website #976

Improved documentation and website

Improved documentation and website #976

Workflow file for this run

name: Main
on:
push:
branches: ["main"]
tags:
- "*-?v[0-9]+*"
pull_request:
branches: ["main"]
types: [opened, synchronize]
env:
GHCR_REGISTRY: ghcr.io
DOCKER_USERNAME: ignisda
permissions:
contents: write
packages: write
jobs:
pre-workflow-checks:
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.set_outputs.outputs.should-run }}
image-names: ${{ steps.set_outputs.outputs.image-names }}
should-release: ${{ steps.set_outputs.outputs.should-release }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set outputs
id: set_outputs
uses: actions/github-script@v7
with:
script: |
const repositoryName = context.payload.repository.name;
const owner = context.repo.owner;
const ghcrRegistry = process.env.GHCR_REGISTRY;
const dockerUsername = process.env.DOCKER_USERNAME;
let imageNames = [
`name=${dockerUsername}/${repositoryName}`,
`name=${ghcrRegistry}/${owner}/${repositoryName}`,
`name=${dockerUsername}/${repositoryName}-pro`,
`name=${ghcrRegistry}/${owner}/${repositoryName}-pro`,
];
let shouldRun = 'false';
if (context.eventName === "push") {
shouldRun = 'true';
} else if (context.eventName === "pull_request") {
const commitMsg = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.payload.pull_request.head.sha
}).then(commit => commit.data.commit.message);
if (commitMsg.includes("Run CI")) {
shouldRun = 'true';
}
}
core.setOutput('should-run', shouldRun);
const shouldRelease = (context.eventName === "push" && context.ref.startsWith("refs/tags/")) ? 'true' : 'false';
core.setOutput('should-release', shouldRelease);
core.setOutput('image-names', imageNames.join('\n'));
create-release:
needs:
- pre-workflow-checks
if: needs.pre-workflow-checks.outputs.should-release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
uses: metcalfc/[email protected]
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body: |
## What's Changed
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-transactional:
needs: pre-workflow-checks
if: needs.pre-workflow-checks.outputs.should-run == 'true'
runs-on: ubuntu-latest
env:
MOON_TOOLCHAIN_FORCE_GLOBALS: true
steps:
- uses: actions/checkout@v4
- uses: moonrepo/setup-toolchain@v0
with:
auto-install: true
- name: Set up Node.js and caching
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: Build emails
run: moon run transactional:build
- name: Upload templates artifact
uses: actions/upload-artifact@v4
with:
name: templates
path: |
crates/services/notification/templates/
retention-days: 1
build-backend:
needs:
- pre-workflow-checks
- build-transactional
if: needs.pre-workflow-checks.outputs.should-run == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- target: x86_64-unknown-linux-gnu
command: cargo
- target: aarch64-unknown-linux-gnu
command: cross
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: templates
path: ${{ github.workspace }}/crates/services/notification/templates
- name: Extract build information
id: build
env:
TARGET: ${{ matrix.platform.target }}
run: |
echo "version=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT"
echo "docker-arch=${{ startsWith(matrix.platform.target, 'x86_64') && 'amd64' || 'arm64' }}" >> "$GITHUB_OUTPUT"
- name: Extract rust toolchain
id: toolchain
run: |
echo "channel=$(grep channel rust-toolchain.toml | awk -F' = ' '{printf $2}' | tr -d '\"')" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain.outputs.channel }}
targets: ${{ matrix.platform.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.platform.target }}-${{ steps.build.outputs.profile }}
save-if: ${{ github.event_name != 'pull_request' }}
- uses: actions/cache@v4
with:
path: target
key: cargo-build-${{ runner.os }}-${{ matrix.platform.target }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
cargo-build-${{ runner.os }}-${{ matrix.platform.target }}-
- name: Install cross
if: ${{ matrix.platform.command == 'cross' }}
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cross
git: https://github.com/cross-rs/cross
rev: 19be83481fd3e50ea103d800d72e0f8eddb1c90c
locked: false
- name: Build
env:
APP_VERSION: ${{ steps.build.outputs.version }}
DEFAULT_TMDB_ACCESS_TOKEN: ${{ secrets.DEFAULT_TMDB_ACCESS_TOKEN }}
DEFAULT_MAL_CLIENT_ID: ${{ secrets.DEFAULT_MAL_CLIENT_ID }}
TRAKT_CLIENT_ID: ${{ secrets.TRAKT_CLIENT_ID }}
UNKEY_API_ID: ${{ secrets.UNKEY_API_ID }}
run: |
${{ matrix.platform.command }} build --locked --target ${{ matrix.platform.target }} --release
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: backend-${{ steps.build.outputs.docker-arch }}
path: ${{ github.workspace }}/target/${{ matrix.platform.target }}/release/backend
retention-days: 1
build-docker:
needs:
- pre-workflow-checks
- build-backend
if: needs.pre-workflow-checks.outputs.should-run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build artifact for docker
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/artifact/
- 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 ghcr container registry
uses: docker/login-action@v3
continue-on-error: true
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the docker hub container registry
uses: docker/login-action@v3
continue-on-error: true
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ needs.pre-workflow-checks.outputs.image-names }}
tags: |
type=ref,event=pr
type=raw,value=develop,enable={{is_default_branch}}
type=semver,pattern=v{{version}},enable=${{ needs.pre-workflow-checks.outputs.should-release == 'true' }}
type=semver,pattern=v{{major}}.{{minor}},enable=${{ needs.pre-workflow-checks.outputs.should-release == 'true' }}
type=semver,pattern=v{{major}},enable=${{ needs.pre-workflow-checks.outputs.should-release == 'true' }}
type=raw,value=latest,enable=${{ needs.pre-workflow-checks.outputs.should-release == 'true' }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
upload-kodi-plugin:
needs:
- pre-workflow-checks
- build-docker
if: needs.pre-workflow-checks.outputs.should-release == 'true'
runs-on: ubuntu-20.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MOON_TOOLCHAIN_FORCE_GLOBALS: true
steps:
- uses: actions/checkout@v4
- name: Setup Moon
uses: moonrepo/setup-toolchain@v0
with:
auto-install: true
- name: Set up Node.js and caching
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- 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-docs:
needs:
- pre-workflow-checks
- build-docker
if: needs.pre-workflow-checks.outputs.should-release == 'true'
runs-on: ubuntu-latest
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