Create prod-deploy.yml #2
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: Deploy to production environment | |
on: | |
push: | |
branches: | |
- "prod" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: prod | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Deploy on AWS EC2 | |
uses: easingthemes/ssh-deploy@main | |
with: | |
SSH_PRIVATE_KEY: ${{ secrets.AWS_EC2_SSH_PRIVATE_KEY }} | |
ARGS: "-rlgoDzvc -i" | |
SOURCE: "./" | |
REMOTE_HOST: ${{ secrets.AWS_EC2_HOSTNAME }} | |
REMOTE_USER: ${{ secrets.AWS_EC2_USERNAME }} | |
TARGET: "~/asset-management/" | |
EXCLUDE: "/dist/, /node_modules/" | |
SCRIPT_BEFORE: | | |
ls -a | |
echo "=================" | |
echo "Update" | |
echo "=================" | |
sudo apt-get update -y | |
echo "=================" | |
echo "Upgrade" | |
echo "=================" | |
sudo apt-get upgrade -y | |
echo "=================" | |
echo "Install rsync" | |
echo "=================" | |
sudo apt-get install -y rsync | |
echo "=================" | |
echo "Create Directory" | |
echo "=================" | |
mkdir -p asset-management | |
SCRIPT_AFTER: | | |
ls -a | |
echo "=================" | |
echo "Change current directory to asset-management" | |
echo "=================" | |
cd asset-management | |
echo "=================" | |
echo "Start Production Deploy Script" | |
echo "=================" | |
sudo chmod +x ./prod-deploy.sh | |
./prod-deploy.sh |