openpgp-notes/.woodpecker/doc-pages.yml
2023-12-13 15:31:29 +01:00

59 lines
2.2 KiB
YAML

# SPDX-FileCopyrightText: 2023 The "Notes on OpenPGP" project
# SPDX-License-Identifier: CC0-1.0
steps:
pages:
image: woodpeckerci/plugin-docker-buildx
settings:
output: type=local,dest=public
# do not push, push cannot be used with output simultaneously anyway
dry_run: true
# do not refresh image
pull_image: false
purge: false
pages-pr-preview:
image: bitnami/git
secrets: [ codeberg_token ]
commands:
- git config --global user.email heiko.schaefer+boiler@posteo.de
- git config --global user.name "Page Renderer"
- git clone -b pages https://$CODEBERG_TOKEN@codeberg.org/openpgp/pr-preview.git pr-preview
- rm -rf pr-preview/$CI_COMMIT_PULL_REQUEST
- cp -ar public/. pr-preview/$CI_COMMIT_PULL_REQUEST
- cd pr-preview
- >
if [ -z "$(git status --porcelain)" ]; then
echo "No changes"
else
git add .
git commit -m "Update rendered page" -m "Source: $CI_COMMIT_SHA" -m "See: $CI_BUILD_LINK"
git push
curl --fail -i -d body="Preview is ready at https://openpgp.codeberg.page/pr-preview/$CI_COMMIT_PULL_REQUEST/" -H "Authorization: token $CODEBERG_TOKEN" "https://codeberg.org/api/v1/repos/$CI_REPO/issues/$CI_COMMIT_PULL_REQUEST/comments"
fi
when:
event: pull_request
pages-publish:
image: bitnami/git
secrets: [ codeberg_token ]
commands:
- git config --global user.email heiko.schaefer+boiler@posteo.de
- git config --global user.name "Page Renderer"
- git clone -b pages https://$CODEBERG_TOKEN@codeberg.org/openpgp/site.git $CI_REPO_NAME
- cp -ar public/. $CI_REPO_NAME/book/
# Needed for custom domains
- cp .domains $CI_REPO_NAME || true # Ignore if it doesn't exist
- cd $CI_REPO_NAME
- >
if [ -z "$(git status --porcelain)" ]; then
echo "No changes"
else
git add .
git commit -m "Update rendered page" -m "Source: $CI_COMMIT_SHA" -m "See: $CI_BUILD_LINK"
git push
fi
when:
event: push
# only do releases to the `site` repo for the "main" branch
branch: main