23.07.01
오늘 한 일
-
TIL
레포지토리에 올리면 자동으로DogSounds-TIL
레포지토리에서 빌드되도록 설정 시도 - algolia 자동화 시도
하루 요약
- 14:00 ~ 17:30, 19:00 ~ 20:30 : 카공
오늘 본 글
✨
당근미니
karrotmini site
karrotmini repo
- 숨겨져 있는 당근 레포를 우연히 찾았다! 이게 찐 사내 코드??
다른 분의 TIL
- 이슈로 관리하시는 것 같다. 형식도 깔끔하고 좋은 것 같아 참고해야겠다.
DogSounds TIL
TL;DR
TIL
레포지토리에 올리면 자동으로DogSounds-TIL
레포지토리에서 빌드되도록 설정 시도 ->성공
- algolia 자동화 시도 ->
실패
TIL
레포지토리에 올리면 자동으로 DogSounds-TIL
레포지토리에서 빌드되도록 설정 시도
문제
TIL
레포지토리에 올리면 자동으로DogSounds-TIL
레포지토리에서 빌드되도록 설정하고 싶었다.
시도
ci 설정
TIL
레포지토리에 github action을 추가했다. 이때 어제 찾아봤던github-action-push-to-another-repository 액션을 사용했다.
name: CI
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
container:
pandoc/latex # "ubuntu" is a more generic container
# using "pandoc/latex" because of dependencies
# used in the specific "build.sh"
steps:
- uses: actions/checkout@v2
- name: creates output
run:
sh ./build.sh # some command from your repository that creates
# output to "source-directory" ("output" in the example)
- name: Pushes to another repository
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.ACCESS_TOKEN }}
with:
source-directory: 'output/'
destination-github-username: 'self-driven-development'
destination-repository-name: 'Dogsounds-TIL'
user-email: kangju2000@naver.com
target-branch: main
target-directory: docs/
commit-message: ${{ github.event.commits[0].message }}
처음엔 source-directory
에 테스트 파일을 넣고 돌렸더니 Dogsounds-TIL
레포 파일이 다 사라져버렸다 ㅋㅋ 그래서 reset하고 테스트하는 동안에는 target-branch
를 test
로 설정했다.
build.sh
파일을 만들어서TIL
레포지토리에 있는 파일들을output
폴더에 복사하도록 했다.
시행착오
TIL 폴더 구조가 23.06/강주혁/06.01.md
이런식으로 되어있는데, 나는 이걸 강주혁/23.06/06.01.md
로 바꾸고 싶었다. 그래서 build.sh
파일을 수정해서 터미널에서 테스트를 계속 해보았다.
chmod +x build.sh
rm -rf ./output && ./build.sh
shell script를 잘 몰라서 GPT 사용해서 해봤지만 뜻대로 되지 않았다..
그래서 기존의 폴더 구조를 변경하기로 했다. 그러면 build.sh
작성이 쉬울 것 같았다.
결과
#!/bin/bash
output_dir="output"
folders=$(ls -d */)
mkdir -p "$output_dir"
cp "README.md" output/index.md
for folder in $folders; do
folder_name=$(basename "$folder")
cp -R "$folder_name" output/
done
이제 TIL
레포지토리에 파일을 올리면 자동으로 DogSounds-TIL
레포지토리에 빌드되어 올라가게 된다.
추가 작업
TIL
main 브랜치에 푸시할 때마다 빌드하지 않고, 하루에 한번씩 빌드하도록 설정하고 싶었다.
시도
ci.yml
파일을 수정했다.
name: CI
on:
schedule:
- cron: '0 0 * * *'
# ...
UTC 기준으로 0시 0분에 실행되도록 설정했다. 그러면 한국 시간으로는 오전 9시에 실행된다. 내일 한번 되는지 확인해봐야겠다.
algolia 자동화 시도
문제
- algolia에 자동으로 업데이트 되도록 설정해서 최근 올라온 것들도 검색할 수 있도록 하고 싶었다.
시도
yml 파일을 수정했다.
name: Update Algolia index
on:
push:
branches: [main]
jobs:
update-index:
name: Update Algolia index
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Push indices to Algolia
uses: signcl/docsearch-scraper-action@master
env:
APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
CONFIG: '{"index_name": "til","start_urls": ["https://self-driven-development.github.io/Dogsounds-TIL/"],"sitemap_urls": ["https://self-driven-development.github.io/Dogsounds-TIL/sitemap.xml"],"sitemap_alternate_links": true,"stop_urls": [],"selectors": {"lvl1": "header h1","lvl2": "article h2","lvl3": "article h3","lvl4": "article h4","lvl5": "article h5, article td:first-child","lvl6": "article h6","text": "article p, article li, article td:last-child"},"strip_chars": " .,;:#","custom_settings": {"separatorsToIndex": "_","attributesForFaceting": ["language","version","type","docusaurus_tag"],"attributesToRetrieve": ["hierarchy","content","anchor","url","url_without_anchor","type"]}}'
결과
- 에러가 뜬다..
# darrenjennings/algolia-docsearch-action@master 사용 시
algoliasearch.exceptions.AlgoliaUnreachableHostException: Unreachable hosts
# signcl/docsearch-scraper-action@master 사용 시
TypeError: string indices must be integers
고민
수동으로 업데이트를 할 때는 docker로 실행해서 업데이트했다. github action으로 docker를 실행해서 업데이트를 하면 되지 않을까?
아직 시도는 안해봤다. 다음에 해봐야겠다.
추가로 할 것
- 메인 페이지 디자인
- md 파일에서 하지 말아야 할 것들 정리해서 올리기 (mdx 이슈)
- md lint
- 내가 본 글은 회색으로 표시되도록?
- 계속 커밋 푸시하기 귀찮다.. 자동화 시도해보기
- 명령어 하나로 커밋 푸시하도록
내일 할 일
- CS 스터디 공부
- Nest.js 강의
- algolia 자동화 시도