-
Notifications
You must be signed in to change notification settings - Fork 37
51 lines (44 loc) · 1.38 KB
/
AutoUpdateGithubPages.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
name: Auto Update to Github Pages.
on:
push:
branches: [ main ]
paths:
- '**.md'
- 'scripts/convert.py'
- 'scripts/convert.yaml'
- '.github/workflows/AutoUpdateGithubPages.yml'
env:
REPO_SSH: [email protected]:SWHL/AI-Competition-Collections.git
USER_NAME: SWHL
USER_EMAIL: [email protected]
CLONE_DIR: AI-Competition-Collections
SUBMMIT_BRANCH: hugo_source
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set SSH Environment
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
git config --global user.name $USER_NAME
git config --global user.email $USER_EMAIL
- name: Convert all md files to hugo format.
run: |
pip install PyYAML
git clone $REPO_SSH ${CLONE_DIR}
cd ${CLONE_DIR}/scripts
python convert.py
- name: Summit repo to hugo_source branch.
run: |
git clone -b ${SUBMMIT_BRANCH} $REPO_SSH ${SUBMMIT_BRANCH}
cd ${SUBMMIT_BRANCH}
rm -r content
cp -r ../${CLONE_DIR}/content .
git add .
git status
git commit -m 'Actions auto update' && git push -f origin ${SUBMMIT_BRANCH} || echo "No changes to commit"