generated from geo-smart/simple-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into scottyhq-patch-1
- Loading branch information
Showing
4 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: PR Build | ||
|
||
on: | ||
pull_request: | ||
# when using teardown: 'true', add default event types + closed event type | ||
types: [opened, synchronize, reopened, closed] | ||
|
||
#permissions: | ||
# pull-requests: write # allow surge-preview to create/update PR comments | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
# environment: SurgePreviewPR | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -el {0} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Conda environment with Micromamba | ||
uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
environment-file: environment.yml | ||
cache-environment: true | ||
|
||
- name: Build JupyterBook | ||
run: | | ||
jb build book | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: html | ||
path: book/_build/html |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: PR Preview | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["PR Build"] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
pull-requests: write # allow surge-preview to create/update PR comments | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.workflow_run.id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
preview: | ||
# environment: SurgePreviewPR | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} | ||
|
||
steps: | ||
# - name: Debug step | ||
# run: | | ||
# echo "workflow_run: ${{toJSON(github.event.workflow_run)}}" | ||
# echo "workflow_run.head_sha: ${{github.event.workflow_run.head_sha}}" | ||
|
||
- uses: actions/download-artifact@v4 | ||
with: | ||
github-token: ${{ github.token }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
path: html | ||
# name: my-other-artifact | ||
# github-token: ${{ secrets.GH_PAT }} # token with actions:read permissions on target repo | ||
# repository: actions/toolkit | ||
# run-id: 1234 | ||
|
||
- name: List directory contents | ||
run: | | ||
pwd | ||
ls -lh | ||
ls html | ||
ls html/* | ||
du -sh * | ||
# - name: download dist artifact | ||
# uses: dawidd6/action-download-artifact@v5 | ||
# with: | ||
# workflow: ${{ github.event.workflow_run.workflow_id }} | ||
# name: pr-build-dist # must be kept in sync with the artifact name downloaded in the build stage | ||
# path: site/ | ||
|
||
- name: Manage Surge deployment | ||
uses: afc163/surge-preview@v1 | ||
with: | ||
surge_token: ${{ secrets.SURGE_TOKEN }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
build: ls * | ||
dist: html | ||
failOnError: true | ||
teardown: true |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: PRT Preview | ||
|
||
# based on https://michaelheap.com/access-secrets-from-forks/ | ||
on: | ||
pull_request_target: | ||
# when using teardown: 'true', add default event types + closed event type | ||
types: [opened, synchronize, reopened, closed] | ||
|
||
permissions: | ||
pull-requests: write # allow surge-preview to create/update PR comments | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
preview: | ||
# environment: SurgePreviewPR | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -el {0} | ||
steps: | ||
- name: Get User Permission | ||
id: checkAccess | ||
uses: actions-cool/check-user-permission@v2 | ||
with: | ||
require: write | ||
username: ${{ github.triggering_actor }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check User Permission | ||
if: steps.checkAccess.outputs.require-result == 'false' | ||
run: | | ||
echo "${{ github.triggering_actor }} does not have permissions on this repo." | ||
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
echo "Job originally triggered by ${{ github.actor }}" | ||
exit 1 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} # This is dangerous without the first access check | ||
|
||
- name: Install Conda environment with Micromamba | ||
uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
environment-file: environment.yml | ||
cache-environment: true | ||
|
||
- name: Build JupyterBook | ||
run: | | ||
jb build book | ||
- name: Build and Publish to Surge | ||
id: preview_step | ||
uses: afc163/surge-preview@v1 | ||
with: | ||
surge_token: ${{ secrets.SURGE_TOKEN }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
dist: book/_build/html | ||
teardown: true | ||
failOnError: true | ||
# website already built in previous step, just list existing folder | ||
build: echo 'skipping website build' | ||
|
||
- name: Format preview url | ||
id: format_url | ||
run: | | ||
echo "url_text=:rocket: Preview deployed at https://${{ steps.preview_step.outputs.preview_url }}" >> $GITHUB_OUTPUT | ||
- name: Get the preview_url | ||
run: echo "${{ steps.format_url.outputs.url_text }}" | ||
|
||
- name: Generate summary | ||
run: | | ||
echo "#### ${{ steps.format_url.outputs.url_text }}" >> $GITHUB_STEP_SUMMARY |