backslash change #1
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: klaytn-docs-docusaurus dev deploy workflow | |
on: | |
push: | |
branches: | |
- klaytn-docs-v2 | |
jobs: | |
# check_link: | |
# name: check_link | |
# runs-on: ubuntu-latest | |
# | |
# container: | |
# image: kjhman21/liche | |
# options: --user root | |
# | |
# steps: | |
# - name: Checkout code | |
# uses: actions/checkout@v2 | |
# | |
# - name: Check links | |
# run: | | |
# ls -la | |
# cd .. | |
# ls -la | |
# /liche -c 1 -t 10 -x "http[s]?://localhost" -r klaytn-docs/ --document-root klaytn-docs/docs | |
check_readability: | |
name: check_readability | |
runs-on: ubuntu-latest | |
container: | |
image: groundx/ci-readability:alpha | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Check readability | |
run: | | |
mkdir -p test-results/readability | |
export pr_only_changed=true | |
export check_regular_commits=false | |
export path_regex="\.(md|txt)$" | |
export path_exclude_regex=SUMMARY.md | |
echo ${{ github.event_name }} | |
echo $path_regex | |
if [ "$pr_only_changed" = "true" ] && [ "${{ github.event_name }}" == "pull_request" ]; then | |
echo "This is a pull request. Limiting readability test to changed files." >&2 | |
PR_NUMBER=$(echo "${{ github.ref }}" | sed -n 's/refs\/pull\/\([0-9]*\)\/merge/\1/p') | |
echo "PR number is $PR_NUMBER" | |
PR_FILES_URL="https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/files" | |
CHANGED_FILES=$(curl -s -u "${{ secrets.GITHUB_BASIC_AUTH }}" "$PR_FILES_URL" | jq -r '.[].filename') | |
elif [ "$check_regular_commits" = "true" ]; then | |
echo "Testing all files." >&2 | |
git ls-files | |
else | |
echo "This is not a PR. Readability test skipped." >&2 | |
fi | \ | |
(grep -E '$path_regex' ||:) | \ | |
(grep -vE '$path_exclude_regex' ||:) | \ | |
xargs testrunner.py > test-results/readability/result.xml | |
cat test-results/readability/result.xml | |
deploy: | |
name: deploy | |
needs: [check_readability] | |
permissions: | |
id-token: write | |
contents: read | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Get AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN_DEV }} | |
role-session-name: SessionForKlaytnActions | |
aws-region: ${{ secrets.AWS_REGION_DEV }} | |
- name: Installing Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
- name: Installing dependencies | |
run: | | |
yarn install | |
- name: Build static files | |
run: yarn build | |
- name: Sync to S3 bucket and validation cloudfront | |
env: | |
S3_BUCKET_DEV: ${{ secrets.S3_BUCKET_DEV }} | |
CLOUDFRONT_ID_DEV: ${{ secrets.CLOUDFRONT_ID_DEV }} | |
run: | | |
aws s3 sync ./build/ $S3_BUCKET_DEV/klaytn-docs --delete | |
aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_ID_DEV --paths "/*" |