-
Notifications
You must be signed in to change notification settings - Fork 71
89 lines (80 loc) · 2.96 KB
/
rdme-staging.yml
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
name: Generate ReadMe Staging 🦉
on:
# run this workflow on all PRs that have reference dirs changed
pull_request:
paths:
- 'openapi/**'
- 'reference/**'
- '.github/actions/**'
- '.github/workflows/rdme-staging.yml'
jobs:
# ////////////////////////////////////////////////////////////////////////
# Pull Request
# ////////////////////////////////////////////////////////////////////////
# Create a new ReadMe Version if it needs to and pushes content to the version
rdme-staging:
if: ${{ github.event.pull_request.head.repo.full_name == 'mixpanel/docs' }}
runs-on: ubuntu-latest
steps:
- name: Check out repo 📚
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- run: npm ci
- name: Add node_modules to PATH
run: echo "$PWD/node_modules/.bin" >> $GITHUB_PATH
# Try to create the readme version, if it errors it's ok we keep going since it was already created
- name: Create readme version
run: |
if rdme versions:create 0.0-pr-${{ github.event.number }} --key=${{ secrets.README_API_KEY }} --fork=v3.26 --main=false --beta=false --deprecated=false --isPublic=true; then
echo "Version created successfully"
else
echo "Errors because the version already exists, and so we can continue to the next step"
fi
- name: Push docs to staging env 🚀
uses: readmeio/rdme@v10
with:
rdme: docs ./reference --key=${{ secrets.README_API_KEY }} --version=0.0-pr-${{ github.event.number }}
# Push openapi specs to staging env
- run: npm run api:build
- run: npm run api:publish
env:
README_API_KEY: ${{ secrets.README_API_KEY }}
README_VERSION: 0.0-pr-${{ github.event.number }}
# build and update comment with the proper link
preview-notify:
name: Preview / Notify
runs-on: ubuntu-20.04
needs:
- rdme-staging
timeout-minutes: 15
permissions:
contents: read
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.github
reference
# Build PR Comment
- name: Build PR comment
id: build-pr-comment
uses: actions/github-script@v7
with:
result-encoding: string
script: |
return `
# API Reference Preview
:rocket: https://developer.mixpanel.com/v0.0-pr-${{ github.event.number }}/reference/overview
Last updated: ${new Date().toLocaleString("en-US", {timeZone: "America/Los_Angeles"})} PT from ${{github.sha}}
`
# Update PR Comment
- uses: ./.github/actions/create-or-update-comment
with:
issue-number: ${{ github.event.number }}
key: reference-pr-preview
body: ${{ steps.build-pr-comment.outputs.result }}