migrate docs to Openlineage/Openlineage repo #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Deploy spec to Netlify | ||
on: | ||
push: | ||
branches: # should be pull request | ||
- migrate-docs | ||
#- main # spec is released whenever pushed to main | ||
jobs: | ||
generate_spec: | ||
# if: github.event.pull_request.merged == true | ||
name: 'Commit Spec definition' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
fetch-depth: 2 | ||
- name: Check & Commit spec changes | ||
run: | | ||
# check if there are any changes in spec in the latest commit | ||
if git diff --name-only --exit-code HEAD^ HEAD -- 'spec/*.json' 'spec/OpenLineage.yml' >> /dev/null; then | ||
echo "no changes in spec detected, skipping publishing spec" | ||
exit 0 | ||
fi | ||
# Copy changed spec JSON files to target location | ||
git diff --name-only HEAD^ HEAD -- 'spec/*.json' | while read LINE; do | ||
# ignore registry files | ||
if [[ $LINE =~ "registry.json" ]]; then | ||
continue | ||
fi | ||
# extract target file name from $id field in spec files | ||
URL=$(cat $LINE | jq -r '.["$id"]') | ||
# extract target location in website repo | ||
LOC="website/static/${URL#*//*/}" | ||
LOC_DIR="${LOC%/*}" | ||
# create dir if necessary, and copy files | ||
echo "change detected in $LINE" | ||
mkdir -p $LOC_DIR | ||
cp $LINE $LOC | ||
done | ||
# verify if there are any changes | ||
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git fetch | ||
git checkout main | ||
git add website/static/spec/* | ||
git commit -m "[generated] adding spec changes" | ||
git push | ||
else | ||
echo "nothing to commit" | ||
fi | ||
netlify_deploy: | ||
# if: github.event.pull_request.merged == true | ||
name: 'Deploy to Netlify' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Repository Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
cache-dependency-path: website/package-lock.json | ||
- name: Install Netlify | ||
run: | | ||
cd website | ||
npm install [email protected] -g | ||
- name: Install Dependencies | ||
run: | | ||
cd website | ||
yarn | ||
- name: Build project | ||
run: | | ||
cd website | ||
yarn build | ||
- name: Deploy to Netlify | ||
id: netlify_deploy | ||
run: | | ||
cd website/build | ||
netlify deploy \ | ||
--cwd . \ | ||
--site ${{ secrets.NETLIFY_SITE_ID }} \ | ||
--auth ${{ secrets.NETLIFY_TOKEN_SECRET }} | ||
--prod |