Skip to content

fix: update Content-Security-Policy to include additional font source #6

fix: update Content-Security-Policy to include additional font source

fix: update Content-Security-Policy to include additional font source #6

name: Staging Deployment Pipeline
on:
push:
branches:
- staging
jobs:
build:
runs-on: ubuntu-latest
environment:
name: staging
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
npm install
- name: Build project
run: |
npm run build
- name: Prepare build for deployment
run: |
mkdir -p build_output
mkdir -p build_output/artifacts
mv build/* build_output/artifacts/
mv nginx/ build_output/nginx/
mv scripts/ build_output/scripts/
mv Dockerfile.nginx build_output/Dockerfile
mv .gitignore build_output/.gitignore
mv deploy.sh build_output/deploy.sh
mv docker-compose.yml build_output/docker-compose.yml
- name: Set up Git for commit
uses: qoomon/actions--setup-git@v1
with:
user: bot
- name: Commit and Push to Build Branch
run: |
git checkout --orphan build/staging
git rm -rf .
mv build_output/* .
mv build_output/.gitignore .gitignore
timestamp=$(date +"%Y-%m-%d %H:%M:%S (%Z)")
git add .
git commit -m "πŸš€ Build deployed at ${timestamp}"
git push origin build/staging --force
deploy:
name: Execute Deployment Script on Server
needs: build
runs-on: ubuntu-latest
environment:
name: staging
url: https://staging.smswithoutborders.com:19550
steps:
- name: Execute Remote SSH Commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
set -e
cd ${{ secrets.PROJECT_PATH }}
echo "============================"
echo "πŸš€ Deleting local build/staging branch if exists ..."
echo "============================"
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" = "build/staging" ]; then
if git branch --list main; then
git checkout main
elif git branch --list master; then
git checkout master
else
echo "❌ No main or master branch to switch to before deleting build/staging!"
exit 1
fi
fi
if git branch --list build/staging; then
git branch -D build/staging
fi
echo "==============================="
echo "βœ… Local build/staging branch deleted (if existed)"
echo "==============================="
echo "============================"
echo "πŸš€ Fetching all branches ..."
echo "============================"
if ! git fetch --all; then
echo "❌ Error fetching branches!"
exit 1
fi
echo "==============================="
echo "βœ… Branch fetch complete"
echo "==============================="
echo "============================"
echo "πŸš€ Switching to build/staging branch ..."
echo "============================"
if ! git checkout build/staging; then
echo "❌ Error switching to build/staging branch!"
exit 1
fi
echo "==============================="
echo "βœ… Switched to build/staging branch"
echo "==============================="
echo "========================="
echo "πŸš€ Building project ..."
echo "========================="
if ! ${{ secrets.BUILD_CMD }}; then
echo "❌ Error building project!"
exit 1
fi
echo "==========================="
echo "βœ… Project build complete"
echo "==========================="
echo "============================="
echo "Cleaning up staging builds ..."
echo "============================="
if ! ${{ secrets.CLEANUP_CMD }}; then
echo "❌ Error cleaning up builds!"
exit 1
fi
echo "============================="
echo "βœ… Cleanup complete"
echo "============================="