mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Ensure previews use the plugin script from the tree instead of the common one for latest and version releases
77 lines
2.6 KiB
YAML
77 lines
2.6 KiB
YAML
name: Deploy Docs Preview
|
|
on:
|
|
pull_request_target:
|
|
types:
|
|
- closed
|
|
- labeled
|
|
paths:
|
|
- 'docs/**'
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
jobs:
|
|
build-and-deploy:
|
|
if: ${{ github.event.action == 'closed' || (github.event.action == 'labeled' && github.event.label.name == 'preview-docs') }}
|
|
concurrency: publish-gh-pages
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout 🛎️
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
- name: Set up Ruby
|
|
if: ${{ github.event.action == 'labeled' }}
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: 2.6
|
|
- name: Install and Build 🔧
|
|
# don't allow a close to execute anything from the source code
|
|
if: ${{ github.event.action == 'labeled' }}
|
|
run: |
|
|
PR_NUMBER=$(jq -r ".number" "$GITHUB_EVENT_PATH")
|
|
REPO_NAME=$(jq -r ".repository.name" "$GITHUB_EVENT_PATH")
|
|
|
|
# TODO find a way for jekyll to perform this automatically
|
|
convert docs/_assets/images/logo.png -define icon:auto-resize=256,64,48,32,16 docs/favicon.ico
|
|
|
|
# avoid look up of API as it doesn't work from within actions without exposing the GITHUB_TOKEN here which is a security risk
|
|
cat <<EOF >> docs/_config.yml
|
|
repository_nwo: vagrant-libvirt/vagrant-libvirt
|
|
plugin_script_base_path: /${REPO_NAME}/pr-preview/pr-${PR_NUMBER}
|
|
EOF
|
|
|
|
BUNDLE_GEMFILE=./docs/Gemfile bundle install
|
|
BUNDLE_GEMFILE=./docs/Gemfile bundle exec jekyll build --source docs/ --baseurl="/${REPO_NAME}/pr-preview/pr-${PR_NUMBER}" --destination build
|
|
- name: Set action
|
|
run: |
|
|
event_type=$(jq -r ".action" "$GITHUB_EVENT_PATH")
|
|
echo "event_type is $event_type"
|
|
|
|
case $event_type in
|
|
"labeled")
|
|
echo "action set to deploy"
|
|
echo "action=deploy" >> "$GITHUB_ENV"
|
|
;;
|
|
"closed")
|
|
echo "action set to remove"
|
|
echo "action=remove" >> "$GITHUB_ENV"
|
|
;;
|
|
*)
|
|
echo "unknown event type $event_type; no action to take"
|
|
echo "action=none" >> "$GITHUB_ENV"
|
|
;;
|
|
esac
|
|
- name: Deploy preview
|
|
uses: rossjrw/pr-preview-action@v1
|
|
with:
|
|
action: ${{ env.action }}
|
|
source-dir: ./build/
|
|
preview-branch: gh-pages
|
|
umbrella-dir: pr-preview
|
|
- name: Remove label
|
|
uses: actions-ecosystem/action-remove-labels@v1
|
|
if: ${{ always() }}
|
|
with:
|
|
labels: preview-docs
|