Reworked workflows #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create PR preview | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
concurrency: | |
group: preview-${{ github.event.number }} | |
cancel-in-progress: true | |
env: | |
PR: ${{ github.event.number }} | |
TARGET_FOLDER: pr_preview/pr-${{ github.event.number }} | |
TARGET_BRANCH: gh-pages | |
jobs: | |
build-and-deploy-preview: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Python setup | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Build preview website | |
run: mkdocs build -f mkdocs.yml -d website | |
- name: Add preview on gh-pages branch | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: ${{ env.TARGET_BRANCH }} | |
folder: website | |
target-folder: ${{ env.TARGET_FOLDER }} | |
commit-message: Deploy preview for PR ${{ env.PR }} 🛫 | |
force: false | |
# - name: Deploy to Github pages | |
- name: Get date | |
run: echo "DATE=$(date '+%Y-%m-%d %H:%M %Z')" >> $GITHUB_ENV | |
- name: Leave a comment after deployment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: pr-preview | |
number: ${{ env.PR }} | |
message: "\ | |
PR Preview | |
:---: | |
🛫 Deployed preview to | |
https://access-hive.org.au/pr_preview/pr-${{ env.PR }} | |
on branch [${{ env.TARGET_BRANCH }}]\ | |
(${{ github.server_url }}/${{ github.repository }}/tree/${{ env.TARGET_BRANCH }}) \ | |
- ${{ env.DATE }} | |
" |