feat: initial commit #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: Sync main repo to deployed repo | |
on: | |
push: | |
branches: [ main ] | |
env: | |
ORIGINAL_REPO: github.com/DV-Lab/dvlab-document | |
DEPLOYED_REPO: github.com/tranhuyducseven/dvlab-document | |
USERNAME: tranhuyducseven | |
EMAIL: tranhuyducseven@gmail.com | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.SUPER_TOKEN }} | |
- name: Clone repo | |
run : | | |
echo "Clone ${{ env.ORIGINAL_REPO }} && ${{ env.DEPLOYED_REPO }}" | |
git clone https://${{ secrets.SUPER_TOKEN }}@${{ env.ORIGINAL_REPO }}.git origin | |
git clone https://${{ secrets.SUPER_TOKEN }}@${{ env.DEPLOYED_REPO }}.git temp | |
- name: Setup global config | |
run : | | |
- name: Copy files | |
run : | | |
echo "[LOG] Copying all origin files to temp" | |
cp origin/**.**.js temp | |
cp origin/**.js temp | |
cp -r origin/blog temp | |
cp -r origin/docs temp | |
cp origin/package**.json temp | |
cp origin/README.md temp | |
cp -r origin/src temp | |
cp -r origin/static temp | |
cd temp | |
rm -rf .github | |
- name: Push and commit | |
run : | | |
echo "[LOG] Setup global config" | |
git config --global user.email "${{ env.EMAIL }}" | |
git config --global user.name "${{ env.USERNAME }}-bot" | |
git remote set-url origin https://x-access-token:${{ secrets.SUPER_TOKEN }}@${{ env.DEPLOYED_REPO }} | |
cd temp | |
echo "[LOG] Git add and commit" | |
git add . | |
git commit -m "Synchronize from private repository - Triggered by Github Workflows" | |
echo "[LOG] Git push" | |
git push | |
- name: Remove temp folder | |
run : | | |
rm -rf temp | |
rm -rf origin | |
ls -al | |