Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2185bf4

Browse files
scottyhqlsetiawan
andauthored
Bump GitHub Actions (#260)
* update actions steps * update actions steps * add failOnError * follow docs * new approach * cleanup * ci: Update SURGE_TOKEN to be accesed via env * ci: Change preview to use pull_request_target * use workflow_run for surge preview --------- Co-authored-by: Don Setiawan <[email protected]>
1 parent 899d391 commit 2185bf4

File tree

6 files changed

+124
-82
lines changed

6 files changed

+124
-82
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Regularly update Docker tags and Actions steps
12
version: 2
23
updates:
34
- package-ecosystem: "docker"

.github/workflows/main.yaml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
name: CI
1+
name: Deploy Website to GitHub Pages
22

33
on:
44
push:
55
branches: main
6-
pull_request:
7-
branches: main
86

97
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
108
permissions:
@@ -18,19 +16,19 @@ concurrency:
1816
cancel-in-progress: true
1917

2018
jobs:
21-
build-and-deploy:
19+
build:
2220
runs-on: ubuntu-latest
2321

2422
steps:
2523
- name: Checkout repository
26-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2725

2826
- name: Setup JupyterBook Cache
29-
uses: actions/cache@v3
27+
uses: actions/cache@v4
3028
with:
3129
path: _build
3230
# NOTE: change key to "jupyterbook-DATE" to force rebuilding cache
33-
key: jupyterbook-20230707
31+
key: jupyterbook-20240517
3432

3533
- name: Install Conda environment with Micromamba
3634
uses: mamba-org/setup-micromamba@v1
@@ -50,19 +48,31 @@ jobs:
5048
run: |
5149
if (test -a _build/html/reports/*log); then cat _build/html/reports/*log ; fi
5250
53-
- name: Save Build
51+
- name: Save Build Folder
5452
if: always()
55-
uses: actions/upload-artifact@v3
53+
uses: actions/upload-artifact@v4
5654
with:
5755
name: build
5856
path: _build/
5957

60-
- name: Publish to GitHub Pages
61-
if: github.ref == 'refs/heads/main'
62-
uses: peaceiris/actions-gh-pages@v3
58+
- name: Upload Pages Artifact
59+
uses: actions/upload-pages-artifact@v3
6360
with:
64-
github_token: ${{ secrets.GITHUB_TOKEN }}
65-
publish_dir: _build/html
66-
publish_branch: gh-pages
67-
cname: tutorial.xarray.dev
68-
enable_jekyll: false
61+
path: _build/html
62+
63+
# Publish Website to GitHub Pages if built successfully
64+
deploy:
65+
needs: build
66+
if: github.ref == 'refs/heads/main'
67+
runs-on: ubuntu-latest
68+
environment:
69+
name: github-pages
70+
url: ${{ steps.deployment.outputs.page_url }}
71+
72+
steps:
73+
- name: Setup Pages
74+
uses: actions/configure-pages@v5
75+
76+
- name: Deploy to GitHub Pages
77+
id: deployment
78+
uses: actions/deploy-pages@v4

.github/workflows/preview.yaml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/pull_request.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Pull Request Build
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, closed]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
preview:
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
shell: bash -el {0}
17+
steps:
18+
- name: Checkout repository
19+
if: github.event.action != 'closed'
20+
uses: actions/checkout@v4
21+
22+
- name: Setup JupyterBook Cache
23+
if: github.event.action != 'closed'
24+
uses: actions/cache@v4
25+
with:
26+
path: _build
27+
# NOTE: change key to "jupyterbook-DATE" to force rebuilding cache
28+
key: jupyterbook-20240517
29+
30+
- name: Install Conda environment with Micromamba
31+
if: github.event.action != 'closed'
32+
uses: mamba-org/setup-micromamba@v1
33+
with:
34+
environment-file: conda/conda-lock.yml
35+
environment-name: xarray-tutorial
36+
cache-environment: true
37+
38+
- name: Build JupyterBook
39+
if: github.event.action != 'closed'
40+
run: |
41+
jupyter-book build ./ --warningiserror --keep-going
42+
43+
- name: Dump Build Logs
44+
if: github.event.action != 'closed'
45+
run: |
46+
if (test -a _build/html/reports/*log); then cat _build/html/reports/*log ; fi
47+
48+
- name: Upload artifact
49+
if: github.event.action != 'closed'
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: html
53+
path: book/_build/html

.github/workflows/qaqc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
shell: bash -el {0}
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121

2222
- name: Install Conda environment with Micromamba
2323
uses: mamba-org/setup-micromamba@v1

.github/workflows/surge_preview.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Pull Request Preview
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Pull Request Build"]
6+
types:
7+
- completed
8+
9+
permissions:
10+
pull-requests: write # allow surge-preview to create/update PR comments
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.workflow_run.id }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
# NOTE: match job name in pull_request.yaml
18+
preview:
19+
runs-on: ubuntu-latest
20+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
21+
22+
steps:
23+
# Ensure folder exists for PR 'closed' case
24+
- run: mkdir html
25+
26+
# Download built HTML from PR Build workflow
27+
- uses: actions/download-artifact@v4
28+
continue-on-error: true
29+
with:
30+
github-token: ${{ github.token }}
31+
run-id: ${{ github.event.workflow_run.id }}
32+
33+
- name: Manage Surge.sh Deployment
34+
id: preview_step
35+
uses: afc163/surge-preview@v1
36+
with:
37+
surge_token: ${{ secrets.SURGE_TOKEN }}
38+
github_token: ${{ secrets.GITHUB_TOKEN }}
39+
build: echo 'Uploading html/ folder contents to Surge.sh...'
40+
dist: html # NOTE: match upload_artifact name in pull_request.yaml
41+
failOnError: true
42+
teardown: true

0 commit comments

Comments
 (0)