mirror of
https://codeberg.org/forgejo/docs.git
synced 2025-02-08 04:26:39 -05:00
CI: move the preview script to an action
This commit is contained in:
parent
5dde3a4231
commit
3d68e4f36e
1 changed files with 13 additions and 24 deletions
|
@ -26,8 +26,7 @@ jobs:
|
||||||
cd /tmp/website
|
cd /tmp/website
|
||||||
corepack enable
|
corepack enable
|
||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
- name: preview
|
- name: build
|
||||||
if: ${{ secrets.WEBSITETOKEN != '' }}
|
|
||||||
run: |
|
run: |
|
||||||
cd /tmp/website
|
cd /tmp/website
|
||||||
colon=':'
|
colon=':'
|
||||||
|
@ -36,25 +35,15 @@ jobs:
|
||||||
cat src/config.mjs
|
cat src/config.mjs
|
||||||
corepack enable
|
corepack enable
|
||||||
pnpm run build
|
pnpm run build
|
||||||
git clone https://forgejo-website:${{ secrets.WEBSITETOKEN }}@codeberg.org/forgejo/pages /tmp/pages
|
mv dist /tmp
|
||||||
git -C /tmp/pages switch -C $branch
|
- name: preview
|
||||||
mv /tmp/pages/.git dist
|
if: ${{ secrets.WEBSITETOKEN != '' }}
|
||||||
cd dist
|
uses: https://code.forgejo.org/forgejo/action-website-preview@main
|
||||||
git config user.email "ci@forgejo.org" ; git config user.name "forgejo-website"
|
with:
|
||||||
git add .
|
directory: /tmp/dist
|
||||||
git diff-index --quiet HEAD || git commit -m 'publish' -a
|
name: 'docs_pull_${{ env.GITHUB_REF_NAME }}'
|
||||||
remote_branch_present=$(git show-branch refs/remotes/origin/$branch 2>/dev/null || true)
|
pages-token: ${{ secrets.WEBSITETOKEN }}
|
||||||
git push --force origin $branch
|
repository: forgejo/docs
|
||||||
|
repository-host: codeberg.org
|
||||||
# Add PR comment with preview links on PR which were not already deployed
|
repository-token: ${{ secrets.WEBSITETOKEN }}
|
||||||
if [ ! "$remote_branch_present" ]; then
|
pr-number: ${{ env.GITHUB_REF_NAME }}
|
||||||
echo -n '{"body": "Preview ready: https://forgejo.codeberg.page/@'"$branch"'/' > comment.json
|
|
||||||
|
|
||||||
# Add link to 5 first pages with more than 100 changes
|
|
||||||
# awk is actually mawk, which does not support regex interval {n,m}
|
|
||||||
git diff --stat origin/main | awk '/\.html *\| *[0-9][0-9][0-9]+ [+-]*$/ { print $3, $1 }' | sort -rn | head -n5 | cut -d" " -f2 | sed 's/index\.html//' | sed 's#^#\\\\nhttps://forgejo.codeberg.page/@'"$branch"'/#' | tr -d '\n' >> comment.json
|
|
||||||
echo '"}' >> comment.json
|
|
||||||
|
|
||||||
# Post PR comment
|
|
||||||
curl -d @comment.json -H "Content-Type: application/json" -X POST "https://forgejo-website:${{ secrets.WEBSITETOKEN }}@codeberg.org/api/v1/repos/forgejo/docs/issues/${{ env.GITHUB_REF_NAME }}/comments"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue