Update/nft methods #733
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: Get file and author data, validate and update internal links, deploy | |
on: | |
push: | |
branches: ["dev"] | |
pull_request: | |
types: [opened, edited, synchronize, reopened, ready_for_review] | |
jobs: | |
pre_job: | |
# continue-on-error: true # Uncomment once integration is finished | |
runs-on: ubuntu-latest | |
# Map a step output to a job output | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@v5 | |
with: | |
# All of these options are optional, so you can remove them if you are happy with the defaults | |
concurrent_skipping: "never" | |
skip_after_successful_duplicate: "true" | |
do_not_skip: '["pull_request"]' | |
update_lint_get_data: | |
needs: pre_job | |
if: needs.pre_job.outputs.should_skip != 'true' && startsWith(github.head_ref, 'lint-fix-patches') == false && github.event.pull_request.head.repo.full_name == github.repository | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: npm-${{ hashFiles('package-lock.json') }} | |
restore-keys: npm- | |
- name: Generate configs | |
shell: bash | |
run: ${GITHUB_WORKSPACE}/utils/gen_api_methods_table.py | |
- name: Install dependencies | |
shell: bash | |
run: cd utils/js && npm ci | |
- name: Get file and Author data | |
if: github.base_ref == 'main' || github.ref == 'refs/heads/main' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: node utils/js/get_file_author_data.js | |
- name: Validate and Update links | |
run: node utils/js/validate_update_internal_links_userpass.js | |
- name: Check presence of file and dirs | |
run: node utils/js/file_presence_structure_checker.js | |
- name: Verify h1 is present in every file | |
run: node utils/js/h1_presence_format_checker.js | |
- name: Prepare data files for GPTs | |
if: github.base_ref == 'main' || github.ref == 'refs/heads/main' | |
run: node utils/js/create_data_for_gpts.js | |
- name: Ensure change logs are updated | |
if: github.base_ref == 'main' || github.ref == 'refs/heads/main' | |
run: node utils/js/ensure_changelog_update.js | |
- name: Generate Search Index | |
if: github.base_ref == 'main' || github.ref == 'refs/heads/main' | |
run: node utils/js/create_search_index.js | |
- name: Set branch name, commit_sha, lint-fix branch name | |
id: vars | |
shell: bash | |
run: | | |
BRANCH_NAME="${{ github.head_ref || github.ref }}" | |
BRANCH_NAME=${BRANCH_NAME#refs/heads/} | |
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
lint_branch_name="lint-fix-patches/${BRANCH_NAME}" | |
echo "lint_branch_name=$lint_branch_name" >> $GITHUB_OUTPUT | |
echo "sha_short=$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
path: website-komodoplatform.com | |
ssh-key: ${{ secrets.DOCS_UI_SSH_PRIVATE_KEY }} | |
repository: KomodoPlatform/website-komodoplatform.com | |
ref: dev | |
submodules: recursive | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
env: | |
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true" | |
with: | |
node-version: "18.20.4" | |
cache: yarn | |
cache-dependency-path: "**/yarn.lock" | |
- name: Restore cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: | |
nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- | |
- name: Get updated content, Install deps, build, Add no-index headers before pubishing to cloudflare | |
run: | | |
pwd | |
echo $GITHUB_WORKSPACE | |
ls $GITHUB_WORKSPACE | |
cd $GITHUB_WORKSPACE/website-komodoplatform.com/utils | |
./update_mdx_branch.sh ${{ steps.vars.outputs.BRANCH_NAME }} | |
cd .. | |
export CFP=yes | |
yarn install | |
./update-content.sh | |
rsync -avh --delete $GITHUB_WORKSPACE/utils/_fileData.json $GITHUB_WORKSPACE/website-komodoplatform.com/src/data/docs/_fileData.json | |
rsync -avh --delete $GITHUB_WORKSPACE/utils/_searchIndex.json $GITHUB_WORKSPACE/website-komodoplatform.com/src/data/docs/searchIndex.json | |
yarn export | |
echo -e "https://:project.pages.dev/*\n X-Robots-Tag: noindex" > ./out/_headers | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
id: cf_publish | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
projectName: komodo-docs | |
directory: ./website-komodoplatform.com/out | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
wranglerVersion: "3" | |
branch: ${{ steps.vars.outputs.BRANCH_NAME }} | |
- name: Post CF preview url | |
uses: actions/github-script@v6 | |
if: github.event_name == 'pull_request' | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: "Preview for merge commit: ${{ steps.vars.outputs.sha_short }}, available on cloudflare at: ${{ steps.cf_publish.outputs.url }}/en/docs/" | |
}) | |
- name: Update package repos, Install libgconf-2-4, wget, Add Google Chrome repository, Install Google Chrome Stable, Clean up | |
if: github.base_ref == 'main' || github.ref == 'refs/heads/main' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -yq libgconf-2-4 | |
sudo apt-get install -y wget --no-install-recommends | |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list | |
sudo apt-get update | |
sudo apt-get install -y google-chrome-stable --no-install-recommends | |
sudo rm -rf /var/lib/apt/lists/* | |
# Setting environment variable for Puppeteer and generating preview images | |
- name: Set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD and CF_PUBLISH_URL | |
if: github.base_ref == 'main' || github.ref == 'refs/heads/main' | |
run: | | |
echo "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true" >> $GITHUB_ENV | |
echo "CF_PUBLISH_URL=${{ steps.cf_publish.outputs.url }}" >> $GITHUB_ENV | |
- name: Generate Preview Images | |
if: github.base_ref == 'main' || github.ref == 'refs/heads/main' | |
run: | | |
cd $GITHUB_WORKSPACE/website-komodoplatform.com/ | |
git status | |
yarn gen:previewImgs | |
- name: Update mdx repo with preview images | |
if: github.base_ref == 'main' || github.ref == 'refs/heads/main' | |
run: mkdir -p $GITHUB_WORKSPACE/preview-images/optimized/ && mkdir -p $GITHUB_WORKSPACE/preview-images/original/ && rsync -avh --delete $GITHUB_WORKSPACE/website-komodoplatform.com/preview-images-original/ $GITHUB_WORKSPACE/preview-images/original/ && rsync -avh --delete $GITHUB_WORKSPACE/website-komodoplatform.com/public/preview-images/ $GITHUB_WORKSPACE/preview-images/optimized/ && rsync -avh --delete $GITHUB_WORKSPACE/website-komodoplatform.com/src/data/docs/previewImgTimeStamps.json $GITHUB_WORKSPACE/preview-images/previewImgTimeStamps.json | |
- name: Delete repo checked out UI repo | |
run: rm -rf $GITHUB_WORKSPACE/website-komodoplatform.com | |
# - name: Check if diff exists | |
# id: diff_check | |
# run: | | |
# if git diff --quiet; then | |
# echo "NO_DIFF=true" >> $GITHUB_OUTPUT | |
# else | |
# echo "NO_DIFF=false" >> $GITHUB_OUTPUT | |
# fi | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "[Bot] File and author data updated, validated and updated internal links, formatted md content, checked presence of file and dirs based on sidebar, checked presence of h1 in every file, update Komodo DeFi Framework methods table, adds/updates preview images when base is main" | |
committer: GitHub <noreply@github.com> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
branch: ${{ steps.vars.outputs.lint_branch_name}} | |
delete-branch: true | |
title: "[BOT] PR to ${{ steps.vars.outputs.branch_name}}. Lints file structure, file contents, gets author data, Updates Komodo DeFi Framework Methods Table, adds/updates preview images" | |
body: | | |
- File and author data updated, validated and updated internal links, formatted md content, checked presence of file and dirs based on sidebar, checked presence of h1 in every file, Komodo DeFi Framework Methods Table auto-generated | |
labels: | | |
autogenerated | |
reviewers: smk762, gcharang | |
draft: false |