build: package.json에 start 스크립트 추가 #24
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: MarketNawa | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20.x' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build project | |
run: npm run build | |
- name: Install AWS CLI | |
run: | | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install --update | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Generate deployment package | |
run: | | |
mkdir -p .ebextensions | |
cat <<EOF > .ebextensions/00-makeFiles.config | |
files: | |
"/etc/nginx/conf.d/vueapp.conf": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
server { | |
listen 80; | |
server_name _; | |
location / { | |
proxy_pass http://127.0.0.1:8080; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade \$http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host \$host; | |
proxy_cache_bypass \$http_upgrade; | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
} | |
EOF | |
cat <<EOF > Procfile | |
web: node server.js | |
EOF | |
mkdir -p deploy | |
cp -r dist deploy/ | |
cp package.json deploy/ | |
cp server.js deploy/ | |
cp Procfile deploy/ | |
cp -r .ebextensions deploy/ | |
cd deploy && zip -r deploy.zip . | |
- name: Beanstalk Deploy | |
uses: einaregilsson/beanstalk-deploy@v22 | |
with: | |
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
application_name: MarketNawa | |
environment_name: MarketNawa-env | |
version_label: github-action-${{ github.sha }}-${{ github.run_id }}-${{ github.run_number }} | |
region: ap-northeast-2 | |
deployment_package: deploy/deploy.zip | |
use_existing_version_if_available: true | |
continue-on-error: true | |
- name: Fetch Logs from Elastic Beanstalk | |
run: | | |
aws elasticbeanstalk request-environment-info --environment-name MarketNawa-env --info-type tail | |
sleep 30 | |
aws elasticbeanstalk retrieve-environment-info --environment-name MarketNawa-env --info-type tail | |
- name: Check Deployment Status | |
run: | | |
if [ "$?" != "0" ]; then | |
echo "Deployment failed. Please check the logs." | |
exit 1 | |
else | |
echo "Deployment succeeded." | |
fi |