chore: try to change viewCount to BigInt #111
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: CD | |
on: | |
push: | |
branches: [main] | |
jobs: | |
deploy: | |
name: Deploy to ec2 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: npm | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Get Github action IP | |
id: ip | |
uses: haythem/public-ip@v1.2 | |
- name: Setting environment variables.. | |
run: | | |
echo "AWS_DEFAULT_REGION=ap-northeast-2" >> $GITHUB_ENV | |
echo "AWS_SG_ID=sg-0e97c6c9abf8e6f03" >> $GITHUB_ENV | |
- name: Add Github Actions IP to Security group | |
run: | | |
aws ec2 authorize-security-group-ingress --group-id ${{ env.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }} | |
- name: Deploy to Server | |
uses: easingthemes/ssh-deploy@v2.2.11 | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }} | |
REMOTE_HOST: 13.124.205.28 | |
REMOTE_USER: ubuntu | |
TARGET: /home/ubuntu/subcloud | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_KEY" > ~/.ssh/staging.key | |
chmod 600 ~/.ssh/staging.key | |
cat >>~/.ssh/config <<END | |
Host staging | |
HostName $SSH_HOST | |
User $SSH_USER | |
IdentityFile ~/.ssh/staging.key | |
StrictHostKeyChecking no | |
END | |
env: | |
SSH_HOST: 13.124.205.28 | |
SSH_USER: ubuntu | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
- name: Restart pm2 | |
run: ssh staging 'cd /home/ubuntu/subcloud && pm2 start ecosystem.config.js' | |
- name: Remove Github Actions IP from security group | |
run: | | |
aws ec2 revoke-security-group-ingress --group-id ${{ env.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }} | |
if: always() |