-
Notifications
You must be signed in to change notification settings - Fork 4
148 lines (129 loc) · 5.55 KB
/
execute-pr-preview.yaml
File metadata and controls
148 lines (129 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Execute training notebooks for PRs
on:
pull_request:
types: [opened, synchronize, ready_for_review]
permissions:
issues: write
pull-requests: write
jobs:
execute:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Check out documentation repository
uses: actions/checkout@v4
# Reclaim space + create a reserve for deterministic headroom
- name: Free space + create reserve
uses: ./.github/actions/free-disk-space
with:
remove_dotnet: "true"
remove_android: "true"
remove_haskell: "true"
prune_docker: "true"
apt_cleanup: "true"
create_reserve_gb: "3"
# See if site/notebooks/ has updates
# Checks the current PR branch against the target branch
- name: Filter changed files
uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.event.pull_request.base_ref }}
ref: ${{ github.head_ref }}
filters: |
notebooks:
- 'site/notebooks/EXECUTED/**'
- name: Set up Python 3.11
if: steps.filter.outputs.notebooks == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
check-latest: false
- name: Set up Quarto
if: steps.filter.outputs.notebooks == 'true'
uses: quarto-dev/quarto-actions/setup@v2
with:
version: ${{ vars.QUARTO_VERSION }}
# If yes then create the dev.env file for use in execution step
- name: Create dev.env file
if: steps.filter.outputs.notebooks == 'true'
id: create_dev_env
run: |
touch dev.env
echo VM_API_HOST=${{ secrets.PLATFORM_API_HOST }} >> dev.env
echo VM_API_KEY=${{ secrets.PLATFORM_API_KEY }} >> dev.env
echo VM_API_SECRET=${{ secrets.PLATFORM_API_SECRET }} >> dev.env
echo VM_API_MODEL=${{ secrets.PLATFORM_DEV_MODEL }} >> dev.env
# If yes then create the valid.env file for use in execution step
- name: Create valid.env file
if: steps.filter.outputs.notebooks == 'true'
id: create_valid_env
run: |
touch valid.env
echo VM_API_HOST=${{ secrets.PLATFORM_API_HOST }} >> valid.env
echo VM_API_KEY=${{ secrets.PLATFORM_API_KEY }} >> valid.env
echo VM_API_SECRET=${{ secrets.PLATFORM_API_SECRET }} >> valid.env
echo VM_API_MODEL=${{ secrets.PLATFORM_VALID_MODEL }} >> valid.env
# Only execute the demo notebooks for training if .env files are created
- name: Execute demo ValidMind for model development and validation series
if: ${{ vars.ENABLE_DEMO_NOTEBOOK == 'true' && steps.create_dev_env.outcome == 'success' && steps.create_valid_env.outcome == 'success' }}
uses: ./.github/actions/demo-notebook
id: execute_demo_notebook
with:
dev_env: dev.env
valid_env: valid.env
# Demo bucket is in us-east-1
- name: Configure AWS credentials
if: steps.execute_demo_notebook.outcome == 'success'
run: aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }} && aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }} && aws configure set default.region us-east-1
- name: Deploy executed notebooks only
if: steps.execute_demo_notebook.outcome == 'success'
run: aws s3 sync site/_site/notebooks/EXECUTED s3://validmind-docs-staging/site/pr_previews/${{ github.head_ref }}/notebooks/EXECUTED --delete && aws cloudfront create-invalidation --distribution-id ESWVTZYFL873V --paths "/site/pr_previews/${{ github.head_ref }}/notebooks/EXECUTED/*" --no-cli-pager
- name: Post comment with preview URLs
if: steps.execute_demo_notebook.outcome == 'success'
uses: actions/github-script@v6
with:
script: |
const base = `https://docs-staging.validmind.ai/pr_previews/${{ github.head_ref }}`;
const devUrl = `${base}/notebooks/EXECUTED/model_development/1-set_up_validmind.html`;
const valUrl = `${base}/notebooks/EXECUTED/model_validation/1-set_up_validmind_for_validation.html`;
// Delete old preview comments
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
for (const comment of comments) {
if (comment.user.login === 'github-actions[bot]' && comment.body.includes('## Execute training notebooks for PRs')) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}
}
let comment = `## Execute training notebooks for PRs\n\n`;
comment += `✓ INFO: Live previews are available —\n\n`;
comment += `- [Open model development series](${devUrl})\n`;
comment += `- [Open model validation series](${valUrl})\n`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
- name: Release reserve & shrink
if: always()
uses: ./.github/actions/free-disk-space
with:
release_reserve: "true"
remove_paths: |
site/_source/installation
site/_source/release-notes
site/render_errors.log
site/_freeze
dev.env
valid.env
- name: Final disk usage
if: always()
run: df -hT /