mirror of
https://codeberg.org/forgejo/docs.git
synced 2024-11-21 17:36:59 -05:00
de971ac0e2
TODO: - [x] comment out the `git push` once the website has submodules merged in Fixes: https://codeberg.org/forgejo/docs/issues/8 Additionally * Upgrade to node:20 * Exclude the README.md when copying to the preview * Allow forgejo-website to push to main on website ![image](/attachments/14f4f38f-fdb8-4ca7-9aee-d9b7e108d71e) Preview: https://forgejo.codeberg.page/@docs_pull_9/ Reviewed-on: https://codeberg.org/forgejo/docs/pulls/9 Reviewed-by: Loïc Dachary <dachary@noreply.codeberg.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
46 lines
1.6 KiB
YAML
46 lines
1.6 KiB
YAML
name: pr
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
jobs:
|
|
preview:
|
|
runs-on: docker
|
|
container:
|
|
image: node:20
|
|
steps:
|
|
- uses: https://code.forgejo.org/actions/checkout@v3
|
|
- name: get forgejo.org and move the docs
|
|
run: |
|
|
git clone --recursive --depth 1 https://codeberg.org/forgejo/website/ /tmp/website
|
|
apt-get update -qq && apt-get install -qq -y rsync
|
|
rsync -av --delete ./ /tmp/website/forgejo-docs/${{ env.GITHUB_BASE_REF }}/
|
|
- name: install
|
|
run: |
|
|
cd /tmp/website
|
|
corepack enable
|
|
pnpm install --frozen-lockfile
|
|
- name: lint:eslint
|
|
run: |
|
|
cd /tmp/website
|
|
corepack enable
|
|
pnpm run format-ci
|
|
pnpm run lint:eslint
|
|
- name: preview
|
|
if: ${{ secrets.WEBSITETOKEN != '' }}
|
|
run: |
|
|
cd /tmp/website
|
|
colon=':'
|
|
branch=docs_pull_${{ env.GITHUB_REF_NAME }}
|
|
sed -i.orig -e "s|origin$colon '.*|origin$colon 'https$colon//forgejo.codeberg.page',|" -e "s|basePathname$colon '/'|basePathname$colon '/@$branch//'|" src/config.mjs
|
|
cat src/config.mjs
|
|
corepack enable
|
|
pnpm run build
|
|
git clone https://forgejo-website:${{ secrets.WEBSITETOKEN }}@codeberg.org/forgejo/pages /tmp/pages
|
|
git -C /tmp/pages switch -C $branch
|
|
mv /tmp/pages/.git dist
|
|
cd dist
|
|
git config user.email "ci@forgejo.org" ; git config user.name "forgejo-website"
|
|
git add .
|
|
git diff-index --quiet HEAD || git commit -m 'publish' -a
|
|
git push --force origin $branch
|