Skip to content

Commit

Permalink
Merge pull request #77 from brian-rose/preview-madness
Browse files Browse the repository at this point in the history
Post preview link AFTER the deployment to gh-pages
  • Loading branch information
brian-rose authored Jun 9, 2022
2 parents 3b09280 + ca7452e commit 64a3271
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/delete_preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: delete-preview

# Only run this when the main branch changes
on:
pull_request_target:
types: closed

jobs:
delete:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
# Find the PR associated with this push, if there is one.
- uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
# Can be "open", "closed", or "all". Defaults to "open".
state: all
# This will echo "Your PR is 7", or be skipped if there is no current PR.
- run: echo "Your PR is ${PR}"
if: success() && steps.findPr.outputs.number
env:
PR: ${{ steps.findPr.outputs.pr }}
- name: Checkout gh-pages branch
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Delete preview files
run: |
rm -rf _preview/${{ steps.findPr.outputs.pr }}
- name: Commit the changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: gh-pages
commit_message: Delete preview for pull request \#${{ steps.findPr.outputs.pr }}
9 changes: 0 additions & 9 deletions .github/workflows/deploy-book.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ jobs:
if: ${{ steps.findPr.outputs.pr }} != ''
run: rm -rf _preview/${{ steps.findPr.outputs.pr }}

- name: Delete preview
if: ${{ steps.findPr.outputs.pr }} != ''
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _preview/${{ steps.findPr.outputs.pr }}
enable_jekyll: false
destination_dir: _preview/${{ steps.findPr.outputs.pr }}

# Push the book's HTML to github-pages
- name: Deploy to GitHub pages
if: github.ref == 'refs/heads/main'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ jobs:
# Push the book's HTML to github-pages
# This will be published at /_preview/PRnumber/ relative to the main site
- name: Deploy to GitHub pages
id: deploy
if: |
github.event.workflow_run.conclusion == 'success'
&& steps.find-pull-request.outputs.number != ''
Expand All @@ -127,6 +128,7 @@ jobs:
github.event.workflow_run.conclusion == 'success'
&& steps.find-pull-request.outputs.number != ''
&& steps.fc.outputs.comment-id != ''
&& steps.deploy.conclusion == 'success'
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
Expand Down
2 changes: 2 additions & 0 deletions home.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# The Climate Laboratory

**HI MOM**

***A hands-on approach to climate physics and climate modeling***

**By [Brian E. J. Rose][brian], University at Albany**
Expand Down

0 comments on commit 64a3271

Please sign in to comment.