Skip to content

Commit

Permalink
Add permission check to deploy PullRequest command (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoyama010 authored Dec 2, 2023
1 parent 76c7e0e commit fd93af2
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 8 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/deploy_to_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Deploy to Pull Request
on:
issue_comment:
types:
- created

env:
PYVISTA_OFF_SCREEN: 'True'
ALLOW_PLOTTING: true
SHELLOPTS: 'errexit:pipefail'
DISPLAY: ':99.0'

jobs:
permission:
if: |
github.event_name == 'issue_comment'
&& github.event.action == 'created'
&& github.event.issue.pull_request != null
&& startsWith(github.event.comment.body, 'github-actions deploy to pull request')
runs-on: ubuntu-latest
steps:
- uses: sushichop/action-repository-permission@v1
with:
required-permission: write
reaction-permitted: rocket
comment-not-permitted: You don't have permission to deploy. Please ask @pyvista/developers to deploy.
build-doc:
if: |
github.event_name == 'issue_comment'
&& github.event.action == 'created'
&& github.event.issue.pull_request != null
&& startsWith(github.event.comment.body, 'github-actions deploy to pull request')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: '3.9'

- uses: syphar/restore-virtualenv@v1
id: cache-virtualenv
with:
requirement_files: requirements_docs.txt

- name: Install OS Packages
run: |
sudo apt-get update
sudo apt-get install -yqq libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 libopengl0 libegl1
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1400x900x24 -ac +extension GLX +render -noreset
sudo apt-get update
sudo apt-get install libosmesa6-dev libgl1-mesa-dev python3-tk pandoc git-restore-mtime
sudo apt-get install python3-tk xcb
- name: Install Dependencies
run: |
sudo apt -y install libgeos-dev
pip install -r requirements_docs.txt
- name: PyVista Report
run: |
python -c "import pyvista;print(pyvista.Report())"
echo PYVISTA_EXAMPLE_DATA_PATH=$(python -c "import pyvista; print(pyvista.EXAMPLES_PATH)") >> $GITHUB_ENV
- name: Build Documentation
run: make -C doc html SPHINXOPTS="-W --keep-going"

- name: Tar build
run: tar -zcvf doc-build.tar.gz doc/build/

- uses: actions/upload-artifact@v3
with:
name: doc-build
path: doc-build.tar.gz

preview:
if: |
github.event_name == 'issue_comment'
&& github.event.action == 'created'
&& github.event.issue.pull_request != null
&& startsWith(github.event.comment.body, 'github-actions deploy to pull request')
name: Preview Documentation
runs-on: ubuntu-latest
needs: build-doc
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v3
with:
name: doc-build
path: .

- name: UnTar build
run: tar -xzvf doc-build.tar.gz

- name: Zip Notebooks
run: |
cp -r doc/build/html/notebooks/tutorial/ notebooks
zip -r notebooks.zip notebooks/
mv notebooks.zip doc/build/html/
- uses: nwtgck/[email protected]
with:
publish-dir: doc/build/html
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: true
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
8 changes: 0 additions & 8 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
workflow_dispatch:
issue_comment:
types: [created, edited]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -20,9 +18,6 @@ env:

jobs:
build-doc:
if: |
( github.event_name == 'issue_comment' && startsWith(github.event.comment.body, 'github-actions deploy to pull request') )
|| github.event_name != 'issue_comment'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -114,9 +109,6 @@ jobs:

preview:
name: Preview Documentation
if: |
( github.event_name == 'issue_comment' && startsWith(github.event.comment.body, 'github-actions deploy to pull request') )
|| github.event_name != 'issue_comment'
runs-on: ubuntu-latest
needs: build-doc
steps:
Expand Down

3 comments on commit fd93af2

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.