Skip to content

Commit 2dbda43

Browse files
v1.3.7 (#331)
Re-closes #191, specifically [this comment](#191 (comment)). Tested on a personal fork. When a user has the "automatically delete branch on merge" setting enabled, by the time the `build-preview.yaml` workflow runs on pull request close, the branch is already gone and `actions/checkout` fails. There are a few ways to solve this: 1. In the `actions/checkout` step, check out the `main` branch if the event is a PR close (regardless of the "auto-delete" option), or check out the PR branch otherwise. 2. Always try to check out the PR branch, and if it errors (user has the "auto-delete" option on), then try to check out `main`. 3. Only run first half of workflow if PR event != close. Then, always (on any PR activity) run the second half which gets all closed PR numbers and deletes their associated preview folders. 1 or 2 would work going forward, but I opted for the 3rd option because it will retroactively fix user's repos that have been affected by this shortcoming so far, like Casey's: <img height="200" alt="Screenshot 2025-07-29 at 5 50 36 PM" src="https://github.com/user-attachments/assets/51649a7b-3b42-4768-a0dd-6b3d568aa841" /> New template version checklist: - [x] I have updated CITATION and CHANGELOG as appropriate. - [x] I have updated lab-website-template-docs as appropriate. - [x] I have checked the testbed as appropriate.
1 parent f35e909 commit 2dbda43

File tree

8 files changed

+46
-6
lines changed

8 files changed

+46
-6
lines changed

.github/workflows/build-preview.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ jobs:
2222

2323
steps:
2424
- name: Debug dump
25+
if: runner.debug == '1'
2526
uses: crazy-max/ghaction-dump-context@v2
2627

2728
- name: Checkout branch contents
29+
if: github.event.action != 'closed'
2830
uses: actions/checkout@v4
2931
with:
3032
repository: ${{ github.event.pull_request.head.repo.full_name }}
@@ -52,7 +54,30 @@ jobs:
5254
JEKYLL_ENV=production bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path || '' }}/${{ env.PREVIEWS_FOLDER }}/pr-${{ github.event.number }}"
5355
5456
- name: Commit preview to Pages branch
57+
if: github.event.action != 'closed'
5558
uses: rossjrw/pr-preview-action@v1.4.7
5659
with:
5760
source-dir: _site
5861
umbrella-dir: ${{ env.PREVIEWS_FOLDER }}
62+
63+
- name: Checkout Pages branch
64+
uses: actions/checkout@v4
65+
with:
66+
ref: gh-pages
67+
68+
- name: Clean up preview folders
69+
uses: actions/github-script@v7
70+
with:
71+
script: |
72+
const { rm } = require("fs").promises;
73+
const { PREVIEWS_FOLDER } = process.env;
74+
const { owner, repo } = context.repo;
75+
const prs = (await github.rest.pulls.list({ owner, repo, state: "closed" })).data;
76+
for (const { number } of prs)
77+
await rm(`${PREVIEWS_FOLDER}/pr-${number}`, { recursive: true, force: true });
78+
79+
- name: Commit changed files
80+
uses: stefanzweifel/git-auto-commit-action@v5
81+
with:
82+
branch: gh-pages
83+
commit_message: "Clean up previews"

.github/workflows/build-site.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Debug dump
24+
if: runner.debug == '1'
2425
uses: crazy-max/ghaction-dump-context@v2
2526

2627
- name: Checkout branch contents

.github/workflows/first-time-setup.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414

1515
steps:
1616
- name: Debug dump
17+
if: runner.debug == '1'
1718
uses: crazy-max/ghaction-dump-context@v2
1819

1920
- name: Create Pages branch

.github/workflows/update-citations.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929

3030
steps:
3131
- name: Debug dump
32+
if: runner.debug == '1'
3233
uses: crazy-max/ghaction-dump-context@v2
3334

3435
- name: Checkout branch contents

.github/workflows/update-url.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020

2121
steps:
2222
- name: Debug dump
23+
if: runner.debug == '1'
2324
uses: crazy-max/ghaction-dump-context@v2
2425

2526
- name: Get Pages url

.github/workflows/versioning.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Debug dump
24+
if: runner.debug == '1'
2425
uses: crazy-max/ghaction-dump-context@v2
2526

2627
- if: runner.debug == '1'
@@ -94,6 +95,7 @@ jobs:
9495
runs-on: ubuntu-latest
9596
steps:
9697
- name: Debug dump
98+
if: runner.debug == '1'
9799
uses: crazy-max/ghaction-dump-context@v2
98100

99101
- name: Checkout branch contents

CHANGELOG.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,26 @@
22

33
Reference: common-changelog.org
44

5+
## 1.3.7 - 2025-07-31
6+
7+
### Changed
8+
9+
- Improve cleanup of PR preview folders in gh-pages branch.
10+
- Only run debug dump in debug mode to speed up workflow runs.
11+
512
## 1.3.6 - 2025-07-30
613

7-
- Improve behavior and flexibility of ORCID cite plugin
14+
### Changed
15+
16+
- Improve behavior and flexibility of ORCID cite plugin.
817

918
## 1.3.5 - 2025-05-12
1019

11-
###
20+
### Changed
1221

1322
- Fix workflow bug where PR previews on GitHub Actions have broken styles/links/etc.
14-
- Fix tags component relative link bug
15-
- Make Actions workflows a bit more robust
23+
- Fix tags component relative link bug.
24+
- Make Actions workflows a bit more robust.
1625

1726
## 1.3.4 - 2025-02-03
1827

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# citation metadata for the template itself
22

33
title: "Lab Website Template"
4-
version: 1.3.6
5-
date-released: 2025-07-30
4+
version: 1.3.7
5+
date-released: 2025-07-31
66
url: "https://github.com/greenelab/lab-website-template"
77
authors:
88
- family-names: "Rubinetti"

0 commit comments

Comments
 (0)