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:
|
||||
push:
|
||||
@@ -8,35 +8,52 @@ on:
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node:20-bookworm
|
||||
volumes:
|
||||
- /home/deploy/.ssh:/root/.ssh:ro
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Install SSH client
|
||||
run: |
|
||||
apt-get update && apt-get install -y openssh-client rsync
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install deps
|
||||
run: npm ci
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
|
||||
- name: Check SSH keys
|
||||
run: |
|
||||
echo "=== SSH keys available? ==="
|
||||
ls -la /root/.ssh/
|
||||
|
||||
- name: Deploy to web server
|
||||
run: |
|
||||
cd dist
|
||||
tar czf ../portfolio.tar.gz *
|
||||
cd ..
|
||||
# determine build output dir
|
||||
if [ -d build ]; then DIR=build
|
||||
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/
|
||||
ssh -i /root/.ssh/deploy_to_web -o StrictHostKeyChecking=accept-new deploy@91.98.34.152 "cd /tmp && \
|
||||
sudo rm -rf /var/www/louisemard.dev/* && \
|
||||
tar xzf portfolio.tar.gz -C /var/www/louisemard.dev/ && \
|
||||
rm portfolio.tar.gz && \
|
||||
sudo chown -R deploy:www-data /var/www/louisemard.dev/ && \
|
||||
sudo chmod -R 775 /var/www/louisemard.dev/ && \
|
||||
sudo systemctl reload nginx"
|
||||
ssh -i /root/.ssh/deploy_to_web -o StrictHostKeyChecking=accept-new deploy@91.98.34.152 "\
|
||||
sudo rm -rf /var/www/louisemard.dev/* && \
|
||||
sudo tar xzf /tmp/portfolio.tar.gz -C /var/www/louisemard.dev/ && \
|
||||
sudo rm /tmp/portfolio.tar.gz && \
|
||||
sudo chown -R deploy:www-data /var/www/louisemard.dev && \
|
||||
sudo chmod -R 775 /var/www/louisemard.dev && \
|
||||
sudo systemctl reload nginx"
|
||||
|
||||
- name: Deployment success
|
||||
run: echo "✅ Portfolio déployé sur https://louisemard.dev"
|
||||
- name: Success
|
||||
run: echo "✅ Déployé sur https://louisemard.dev"
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -86,3 +86,6 @@ typings/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# Vite react build output
|
||||
dist/
|
||||
Reference in New Issue
Block a user