diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 81be6e7..024a78d 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,21 +1,22 @@ name: Linux arm64 -run-name: Build App +run-name: Build and Deploy Portfolio on: [push] jobs: - Build: + Build-and-Deploy: runs-on: ubuntu-latest steps: - name: Check out repository code uses: actions/checkout@v3 - - name: Build + - name: Install dependencies and build run: | npm ci npm run build - - - uses: webfactory/ssh-agent@v0.9.0 + + - name: Set up SSH agent + uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.SSH_KEY_PORTFOLIO }} @@ -24,11 +25,24 @@ jobs: mkdir -p ~/.ssh ssh-keyscan -H git.ale-pri.com >> ~/.ssh/known_hosts - - uses: actions/upload-artifact@v3 - with: - name: Release Build - path: ${{ github.workspace }}/build - - - name: Deploy + - name: Upload build folder to temporary directory on remote server run: | - scp -r build ubuntu@git.ale-pri.com:Sites/Portfolio \ No newline at end of file + scp -r build ubuntu@git.ale-pri.com:/Poubelle/build + + - name: Deploy to final directory on remote server + run: | + ssh ubuntu@git.ale-pri.com << 'EOF' + BUILD_TMP=/Poubelle/build + DEPLOY_DIR=/var/www/portfolio + + sudo mkdir -p $DEPLOY_DIR + + sudo rsync -a --delete $BUILD_TMP/ $DEPLOY_DIR/ + + sudo chown -R www-data:www-data $DEPLOY_DIR + sudo chmod -R 755 $DEPLOY_DIR + + sudo rm -rf $BUILD_TMP + + sudo nginx -t && sudo systemctl reload nginx + EOF