Automates deployment workflow using Gitea Actions
Some checks failed
Deploy React portfolio / deploy (push) Failing after 1m3s
Some checks failed
Deploy React portfolio / deploy (push) Failing after 1m3s
Sets up a Gitea Actions workflow to automatically build and deploy the React portfolio website to the production server. This includes: - Using a containerized environment for consistent builds. - Installing dependencies and building the project. - Deploying the built files to the web server via SSH and rsync. - Reloading the web server configuration to apply changes. Also, this change updates the .gitignore file to exclude the 'dist' directory.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: Deploy Portfolio
|
name: Deploy React portfolio
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -8,35 +8,52 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: node:20-bookworm
|
||||||
|
volumes:
|
||||||
|
- /home/deploy/.ssh:/root/.ssh:ro
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Install SSH client
|
||||||
|
run: |
|
||||||
|
apt-get update && apt-get install -y openssh-client rsync
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Install deps
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Check SSH keys
|
||||||
|
run: |
|
||||||
|
echo "=== SSH keys available? ==="
|
||||||
|
ls -la /root/.ssh/
|
||||||
|
|
||||||
- name: Deploy to web server
|
- name: Deploy to web server
|
||||||
run: |
|
run: |
|
||||||
cd dist
|
# determine build output dir
|
||||||
tar czf ../portfolio.tar.gz *
|
if [ -d build ]; then DIR=build
|
||||||
cd ..
|
elif [ -d dist ]; then DIR=dist
|
||||||
|
else
|
||||||
|
echo "❌ No build output directory found" >&2
|
||||||
|
ls -la
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Using build dir: $DIR"
|
||||||
|
|
||||||
|
# deploy
|
||||||
|
tar czf portfolio.tar.gz -C "$DIR" .
|
||||||
scp -i /root/.ssh/deploy_to_web -o StrictHostKeyChecking=accept-new portfolio.tar.gz deploy@91.98.34.152:/tmp/
|
scp -i /root/.ssh/deploy_to_web -o StrictHostKeyChecking=accept-new portfolio.tar.gz deploy@91.98.34.152:/tmp/
|
||||||
ssh -i /root/.ssh/deploy_to_web -o StrictHostKeyChecking=accept-new deploy@91.98.34.152 "cd /tmp && \
|
ssh -i /root/.ssh/deploy_to_web -o StrictHostKeyChecking=accept-new deploy@91.98.34.152 "\
|
||||||
sudo rm -rf /var/www/louisemard.dev/* && \
|
sudo rm -rf /var/www/louisemard.dev/* && \
|
||||||
tar xzf portfolio.tar.gz -C /var/www/louisemard.dev/ && \
|
sudo tar xzf /tmp/portfolio.tar.gz -C /var/www/louisemard.dev/ && \
|
||||||
rm portfolio.tar.gz && \
|
sudo rm /tmp/portfolio.tar.gz && \
|
||||||
sudo chown -R deploy:www-data /var/www/louisemard.dev/ && \
|
sudo chown -R deploy:www-data /var/www/louisemard.dev && \
|
||||||
sudo chmod -R 775 /var/www/louisemard.dev/ && \
|
sudo chmod -R 775 /var/www/louisemard.dev && \
|
||||||
sudo systemctl reload nginx"
|
sudo systemctl reload nginx"
|
||||||
|
|
||||||
- name: Deployment success
|
- name: Success
|
||||||
run: echo "✅ Portfolio déployé sur https://louisemard.dev"
|
run: echo "✅ Déployé sur https://louisemard.dev"
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -86,3 +86,6 @@ typings/
|
|||||||
|
|
||||||
# DynamoDB Local files
|
# DynamoDB Local files
|
||||||
.dynamodb/
|
.dynamodb/
|
||||||
|
|
||||||
|
# Vite react build output
|
||||||
|
dist/
|
||||||
Reference in New Issue
Block a user