Adds builder, preps for vercel (#122871)

* Adds builder, preps for vercel

* bumps builder version

* updates tokens

* Updates to target to enable on PRs

* Update builder.yml

fixes fork-based workflows

* Update builder.yml

* Renames to make intent more clear

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Kellen 2022-01-25 12:07:09 -08:00 committed by GitHub
parent 09aac9e42d
commit 1438e97783
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

81
.github/workflows/dev-docs-builder.yml vendored Normal file
View file

@ -0,0 +1,81 @@
name: Elastic Builder
on:
pull_request_target:
paths:
- '**.mdx'
- '**.docnav.json'
- '**.png'
- '**.gif'
types: [closed, opened, synchronize, reopened]
jobs:
preview:
name: Do the magic
runs-on: ubuntu-latest
steps:
- name: Setup workspace
uses: actions/checkout@v2
- name: Checkout current branch into temp
if: github.event.pull_request.merged == false
uses: actions/checkout@v2
with:
path: 'temp'
fetch-depth: 2
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Checkout current branch into temp
if: github.event.pull_request.merged == true
uses: actions/checkout@v2
with:
path: 'temp'
- name: Checkout essential repos
uses: actions/checkout@v2
with:
repository: elastic/docs.elastic.dev
token: ${{ secrets.VERCEL_GITHUB_TOKEN }}
path: ${{ github.workspace }}/docs.elastic.dev
- name: Checkout Wordlake
uses: actions/checkout@v2
with:
repository: elastic/wordlake-dev
token: ${{ secrets.VERCEL_GITHUB_TOKEN }}
path: ${{ github.workspace }}/wordlake-dev
- name: Temp sources override
shell: bash
run: cp -f ${{ github.workspace }}/wordlake-dev/.scaffold/sources.json ${{ github.workspace }}/docs.elastic.dev/.
- name: Show workspace
shell: bash
run: ls -lat ${{ github.workspace }}
- name: Portal
shell: bash
run: |
mkdir -p ${{ github.workspace }}/wordlake-dev/${{ github.event.repository.name }}
rsync --ignore-missing-args -zavpm --include='*.docnav.json' --include='*.mdx' --include='*.png' --include='*.gif' --include='*/' --exclude='*' ${{ github.workspace }}/temp/ ${{ github.workspace }}/wordlake-dev/${{ github.event.repository.name }}/
- name: Generate preview
if: github.event.pull_request.merged == false
uses: elastic/builder@v21.1.0
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} #Required
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_DOCS_DEV}} #Required
vercel-project-name: docs-elastic-dev
github-token: ${{ secrets.VERCEL_GITHUB_TOKEN }} #Optional
working-directory: ./
- name: Portal for deploy
if: github.event.pull_request.merged == true
shell: bash
run: |
cd ${{ github.workspace }}/wordlake-dev
git config user.name count-docula
git config user.email github-actions@github.com
git add .
git commit -m "New content from https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
git push