142 lines
3.8 KiB
YAML
142 lines
3.8 KiB
YAML
---
|
|
name: Docs
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- unlabeled # if GitHub Actions stuck, add and remove "not ready" label to force rebuild
|
|
- opened
|
|
- reopened
|
|
- synchronize
|
|
push:
|
|
branches:
|
|
- main
|
|
- main-*
|
|
- releases/*
|
|
schedule:
|
|
- cron: "12 0 * * *"
|
|
|
|
# Do not run this workflow in parallel for any PR change or branch push
|
|
# to prevent concurrent deployments to GitHub Pages.
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
|
|
cancel-in-progress: false
|
|
|
|
env:
|
|
GOPATH: /home/runner/go
|
|
GOCACHE: /home/runner/go/cache
|
|
GOLANGCI_LINT_CACHE: /home/runner/go/cache/lint
|
|
GOMODCACHE: /home/runner/go/mod
|
|
GOPROXY: https://proxy.golang.org
|
|
GOTOOLCHAIN: local
|
|
|
|
jobs:
|
|
build:
|
|
name: Build docs
|
|
|
|
# https://www.ubicloud.com/docs/about/pricing#github-actions
|
|
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#per-minute-rates-for-larger-runners
|
|
runs-on: ubicloud-standard-2
|
|
|
|
timeout-minutes: 10
|
|
|
|
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')
|
|
|
|
steps:
|
|
# TODO https://github.com/FerretDB/github-actions/issues/211
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
lfs: true
|
|
|
|
# This step will fail with "Error: Resource not accessible by integration"
|
|
# while trying to add label and comment to PR, that is not possible for PRs from forks.
|
|
# See https://github.com/ppremk/lfs-warning/issues/147.
|
|
# But the real issue will be right above that message: a list of files that should be added using Git LFS.
|
|
- name: Check LFS status
|
|
if: false # disabled until release
|
|
uses: ppremk/lfs-warning@v3.3
|
|
with:
|
|
filesizelimit: 102400b
|
|
labelName: use-git-lfs
|
|
exclusionPatterns: |
|
|
**/*.js
|
|
**/*.md
|
|
**/go.sum
|
|
|
|
- name: Setup Go
|
|
uses: FerretDB/github-actions/setup-go@main
|
|
with:
|
|
cache-key: docs
|
|
|
|
- name: Install Task
|
|
run: go generate -x
|
|
working-directory: tools
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build tools
|
|
run: bin/task env-pull
|
|
|
|
- name: Create directory
|
|
run: mkdir -p tmp/githubcache
|
|
|
|
- name: Build docs
|
|
run: bin/task docs
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for checkdocs
|
|
|
|
- name: Archive docs
|
|
run: >
|
|
tar --directory website/build
|
|
--file tmp/docs.tar
|
|
--create
|
|
--verbose
|
|
.
|
|
|
|
# it has to be exactly "docs.tar" for actions/deploy-pages below
|
|
- name: Upload archive artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: docs
|
|
path: tmp/docs.tar
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
|
|
- name: Check dirty
|
|
if: always()
|
|
run: |
|
|
git status --untracked-files --ignored
|
|
git status
|
|
git diff --exit-code
|
|
|
|
github:
|
|
name: Deploy to GitHub Pages
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 10
|
|
|
|
# exclude pull_request and schedule
|
|
needs: build
|
|
# if: github.event_name == 'push'
|
|
if: false # disabled until release
|
|
|
|
permissions:
|
|
pages: write
|
|
id-token: write
|
|
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deploy.outputs.page_url }}
|
|
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deploy
|
|
uses: actions/deploy-pages@v4
|
|
with:
|
|
artifact_name: docs
|
|
timeout: 300000 # 5*60*1000 milliseconds
|