Skip to content

Stage reference changes to readme #29

Stage reference changes to readme

Stage reference changes to readme #29

name: Generate ReadMe Staging 🦉
on:
# when a PR is created in any branch except main that have made changes to the
# reference folder, run this workflow
push:
branches-ignore:
- main
pull_request:
paths:
- 'reference/**'
jobs:
# ////////////////////////////////////////////////////////////////////////
# Pull Request
# ////////////////////////////////////////////////////////////////////////
# Create a new ReadMe Version if it needs to and pushes content to the version
rdme-staging:
runs-on: ubuntu-latest
outputs:
has-version: ${{ steps.check-readme-version.outputs.has-version }}
steps:
- name: Check out repo 📚
uses: actions/checkout@v3
# installs readme so that we can run `rdme` in the conditional step
- name: Install rdme
run: |
npm install -g rdme
- name: Check if the readme version exists
id: check-readme-version
run: |
if rdme versions --version=${{ github.event.pull_request.number }} --key=${{ secrets.README_API_KEY }}; then
echo "has-version=true" >> $GITHUB_ENV
else
echo "has-version=false" >> $GITHUB_ENV
fi
# if it's a new PR, we'll have to create the readme, otherwise we can skip this step
- name: Run create readme version
if: steps.has-version.outputs.has-version == 'false'
uses: readmeio/rdme@v8
with:
rdme: versions:create ${{ github.event.pull_request.number }} --key=${{ secrets.README_API_KEY }} --fork=v3.26 --main=false --beta=false --deprecated=false --isPublic=true
- name: Push docs to staging env 🚀
uses: readmeio/rdme@v8
with:
rdme: docs ./reference --key=${{ secrets.README_API_KEY }} --version=${{ github.event.pull_request.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@v6
with:
result-encoding: string
script: |
return `
# READMe Reference Preview
:rocket: https://https://developer.mixpanel.com/v${{ 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 }}