test #10
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: Copy Files from TIL | |
on: | |
push: | |
branches: [ main ] | |
# schedule: | |
# - cron: '0 15 * * *' # 매일 15:00에 실행 (UTC 기준, KST 기준 자정) | |
jobs: | |
copy_files: | |
env: | |
destination: src/content/docs/TIL | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Clone repository | |
run: | | |
git clone --branch main https://github.com/rlaisqls/TIL.git | |
- name: Add labels | |
run: | | |
add_labels_to_files() { | |
local dir="$1" | |
echo "$dir" | |
cd "$dir" || exit | |
for file in *; do | |
if [ -f "$file" ]; then | |
# title, lastUpdated 속성 추가 | |
echo "---" > tmpfile | |
echo "title: '${file%.*}'" >> tmpfile | |
echo "lastUpdated: '$(git log -1 --format=%cd --date=format:%Y-%m-%d $file)'" >> tmpfile | |
echo "---" >> tmpfile | |
cat "$file" >> tmpfile | |
mv tmpfile "$file" | |
elif [ -d "$file" ]; then | |
add_labels_to_files "$dir/$file" | |
cd "$dir" | |
fi | |
done | |
} | |
ls | |
ls ../ | |
cd TIL | |
pwd | |
add_labels_to_files $(pwd) | |
- name: Copy files | |
run: | | |
pwd | |
echo "" | |
ls | |
ls TIL | |
rm -rf ${{ env.destination }} | |
mkdir ${{ env.destination }} | |
cp -r TIL/* ${{ env.destination }} | |
rm ${{ env.destination }}/README.md | |
rm -rf TIL | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Commit and push | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Copy files from TIL" | |
repository: . | |
branch: main | |
file_pattern: '.' | |
push_options: '--force' | |
commit_options: '--no-verify --signoff' | |
commit_user_name: rlaisqls | |
commit_user_email: rlaisqls@gmail.com | |
commit_author: rlaisqls <rlaisqls@gmail.com> | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |