83 lines
2.7 KiB
YAML
83 lines
2.7 KiB
YAML
name: Deploy Pages
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: "17 */6 * * *"
|
|
|
|
concurrency:
|
|
group: deploy-${{ forgejo.ref }}
|
|
cancel-in-progress: false
|
|
|
|
env:
|
|
PAGE_SERVER: pgs.xlion.dev
|
|
|
|
jobs:
|
|
deploy:
|
|
if: ${{ forgejo.event_name != 'pull_request' || forgejo.event.pull_request.head.repo.full_name == forgejo.repository }}
|
|
runs-on: ha
|
|
timeout-minutes: 35
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://git.xlion.tw/actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- name: Setup uv
|
|
uses: https://github.com/astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
|
|
with:
|
|
version: "0.12.23"
|
|
enable-cache: true
|
|
|
|
- name: Sync runtime dependencies
|
|
run: uv sync --locked --no-dev
|
|
|
|
- name: Build mirror
|
|
run: uv run --locked --no-dev dns-blocklist-mirror --config mirrors.yaml --output public
|
|
|
|
- name: Add static files
|
|
run: cp -R static/. public/
|
|
|
|
- name: Show the size of the public
|
|
run: du -sh public/
|
|
|
|
- name: Resolve repository name
|
|
id: repository
|
|
run: |
|
|
echo "name=${FORGEJO_REPOSITORY#*/}" >> "$FORGEJO_OUTPUT"
|
|
|
|
- name: Deploy production
|
|
if: ${{ forgejo.event_name != 'pull_request' }}
|
|
uses: https://codeberg.org/git-pages/action@2b24bbb7ff943d3c8fe1df91326adec66daea6dd # v2.2.0
|
|
with:
|
|
site: https://${{ forgejo.repository_owner }}.${{ env.PAGE_SERVER }}/${{ steps.repository.outputs.name }}/
|
|
token: ${{ forgejo.token }}
|
|
source: public
|
|
|
|
- name: Deploy PR preview
|
|
if: ${{ forgejo.event_name == 'pull_request' }}
|
|
uses: https://codeberg.org/git-pages/action@2b24bbb7ff943d3c8fe1df91326adec66daea6dd # v2.2.0
|
|
with:
|
|
site: https://${{ forgejo.repository_owner }}.preview.${{ env.PAGE_SERVER }}/${{ steps.repository.outputs.name }}@${{ forgejo.event.number }}/
|
|
token: ${{ forgejo.token }}
|
|
source: public
|
|
|
|
- name: Print deployed mirror URLs
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ forgejo.event_name }}" == "pull_request" ]]; then
|
|
site_url="https://${FORGEJO_REPOSITORY_OWNER}.preview.${PAGE_SERVER}/${{ steps.repository.outputs.name }}@${{ forgejo.event.number }}/"
|
|
else
|
|
site_url="https://${FORGEJO_REPOSITORY_OWNER}.${PAGE_SERVER}/${{ steps.repository.outputs.name }}/"
|
|
fi
|
|
|
|
printf 'Deployed mirror URLs:\n\n'
|
|
find public -mindepth 2 -type f -printf '%P\n' \
|
|
| LC_ALL=C sort \
|
|
| while IFS= read -r relative_path; do
|
|
printf '%s%s\n' "${site_url}" "${relative_path}"
|
|
done
|
|
printf '\n'
|