website/.forgejo/workflows/pr_preview.yml
Andre601's Bot 407cadeead
All checks were successful
Pull Request Preview / createPreview (pull_request_target) Successful in 1m26s
Update https://code.forgejo.org/actions/checkout action to v6
2025-11-21 12:03:29 +00:00

121 lines
No EOL
4.7 KiB
YAML

name: Pull Request Preview
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
paths:
- ".forgejo/workflows/pr_preview.yml"
- "docs/**"
- "theme/**"
- "_redirects"
- "mkdocs.yml"
- "preview_domains"
- "requirements.txt"
workflow_dispatch:
env:
BRANCH_NAME: "${{ github.event.repository.name }}/${{ github.event.pull_request.number }}"
concurrency:
group: page-preview
cancel-in-progress: false
jobs:
createPreview:
runs-on: codeberg-tiny
steps:
#
# Finding and updating comment in Pull request.
# If not found, have one created instead.
#
- name: "Find Comment"
id: find-comment
uses: https://github.com/peter-evans/find-comment@v4
with:
issue-number: "${{ github.event.pull_request.number }}"
comment-author: "Andre_601-Bot"
- name: "Create or update Comment"
id: comment
uses: https://github.com/peter-evans/create-or-update-comment@v5
with:
body: |-
## Pull request Preview
Creating Preview for Pull request. Please wait...
comment-id: "${{ steps.find-comment.outputs.comment-id }}"
issue-number: "${{ github.event.pull_request.number }}"
token: "${{ secrets.BOT_TOKEN }}"
edit-mode: replace
#
# Setup source and target repository.
# Build website and push.
#
- name: "Checkout Source Repository"
uses: https://code.forgejo.org/actions/checkout@v6
with:
token: ${{ secrets.BOT_TOKEN }}
fetch-depth: 0
ref: "${{ github.event.pull_request.head.sha }}"
- name: "Checkout Target Repository"
run: |
git clone https://codeberg.org/Andre601/preview site
cd site
git switch ${{ env.BRANCH_NAME }} 2>/dev/null || git switch -c ${{ env.BRANCH_NAME }}
- name: "Setup Python 3.x"
uses: https://code.forgejo.org/actions/setup-python@v6
with:
python-version: 3.x
- name: "Install Dependencies"
run: "pip install -r requirements.txt"
- name: "Build Website"
run: "mkdocs build"
- name: "Commit and Push"
run: |
git config --global user.email "[email protected]"
git config --global user.name "PR Docs Preview Builder"
mv preview_domains site/.domains
cd site
git remote add upstream https://${{ secrets.BOT_TOKEN }}@codeberg.org/Andre601/preview.git
git add --all
git commit -m "Update Preview for ${{ env.BRANCH_NAME }} ($( env TZ=Europe/Zurich date +"%d.%m.%Y %Z" ))"
git push --set-upstream upstream ${{ env.BRANCH_NAME }} -f
#
# Update comment on success or failure.
#
- name: "Comment Success"
uses: https://github.com/peter-evans/create-or-update-comment@v5
with:
body: |-
## Pull request Preview
Pull request Preview created successfully!
| Name | Link |
|---------|----------------------------------------------------------------------------------------------------------|
| Commit | ${{ github.event.pull_request.head.sha }} |
| Preview | https://preview.andre601.ch/@${{ github.event.repository.name }}~${{ github.event.pull_request.number }} |
| Logs | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
comment-id: "${{ steps.comment.outputs.comment-id }}"
issue-number: "${{ github.event.pull_request.number }}"
token: "${{ secrets.BOT_TOKEN }}"
edit-mode: replace
- name: "Comment Failure"
if: ${{ failure() }}
uses: https://github.com/peter-evans/create-or-update-comment@v5
with:
body: |-
## Pull request Preview
Pull request Preview failed! Check the logs for details.
| Name | Link |
|---------|-------------------------------------------------------------------------------------|
| Commit | ${{ github.event.pull_request.head.sha }} |
| Logs | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
comment-id: "${{ steps.comment.outputs.comment-id }}"
issue-number: "${{ github.event.pull_request.number }}"
token: "${{ secrets.BOT_TOKEN }}"
edit-mode: replace