-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 1.93 KB
/
copy-files-from-til.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Copy Files from TIL
on:
schedule:
- cron: "0 15 * * *" # 매일 KST 기준 자정에 실행 (UTC 기준 15:00)
push:
branches: [ main ]
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 --reverse --format=%cd --date=format:%Y-%m-%dT%H:%M:%S $file | head -n 1)" >> tmpfile
echo "---" >> tmpfile
cat "$file" >> tmpfile
mv tmpfile "$file"
elif [ -d "$file" ]; then
add_labels_to_files "$dir/$file"
cd "$dir"
fi
done
}
add_labels_to_files $(pwd)/TIL
- name: Copy files
run: |
rm -rf ${{ env.destination }}
mkdir ${{ env.destination }}
cp -r TIL/* ${{ env.destination }}
rm ${{ env.destination }}/README.md
rm ${{ env.destination }}/*.json
rm -rf TIL
- name: Set current date as env
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Commit and push
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "${{ env.date }} TIL 문서 복사"
repository: .
branch: main
file_pattern: "."
push_options: "--force"