Merge remote-tracking branch 'origin/main' #10
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: MarketNawaFE | |
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 .platform/nginx/conf.d | |
cat <<EOF > .platform/nginx/conf.d/proxy.conf | |
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; | |
} | |
} | |
EOF | |
cat <<EOF > .platform/nginx/conf.d/health.conf | |
server { | |
listen 80; | |
server_name _; | |
location /health { | |
return 200 'Health Check OK'; | |
add_header Content-Type text/plain; | |
} | |
} | |
EOF | |
mkdir -p deploy | |
cp -r dist deploy/ | |
cp package.json deploy/ | |
cp server.js deploy/ | |
cp Procfile deploy/ | |
cp -r .ebextensions deploy/ | |
cp -r .platform 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: MarketNawaFE | |
environment_name: MarketNawaFE-env | |
version_label: github-action-${{ github.sha }} | |
region: ap-northeast-2 | |
deployment_package: deploy/deploy.zip | |
use_existing_version_if_available: true |