Skip to content

Commit 576c297

Browse files
committed
Action: Add workflow for automated preview deployments on latest
1 parent 8244882 commit 576c297

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

.github/workflows/previews.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: documentation preview
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
pull_request:
8+
branches:
9+
- "*"
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Trigger `Build and deploy` workflow in `documentation` repo
16+
run: |
17+
repo_owner="nginx"
18+
repo_name="documentation"
19+
event_type="trigger-preview-build"
20+
environment="preview"
21+
theme_version="${{ github.head_ref || '' }}" # Will either be the branch name if triggered from pull request, or empty string (aka latest) if triggered from release
22+
23+
curl -L \
24+
-X POST \
25+
-H "Accept: application/vnd.github+json" \
26+
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
27+
-H "X-GitHub-Api-Version: 2022-11-28" \
28+
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
29+
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"environment\": \"$environment\", \"hugo_theme_override\": \"$theme_version\"}}"

.github/workflows/theme-release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
name: Slack notification for new theme release
22

33
on:
4-
release:
5-
types:
6-
- published
4+
workflow_run:
5+
workflows:
6+
- "documentation preview"
7+
types: [completed]
78

89
permissions:
910
contents: read
1011

1112
jobs:
1213
release-notification:
1314
runs-on: ubuntu-latest
15+
if: ${{ github.event.workflow_run.event == 'release' }}
1416
permissions:
1517
contents: read
1618
actions: read # for 8398a7/action-slack

0 commit comments

Comments
 (0)