just use dist #7
Workflow file for this run
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: (Prod) Build and deploy | |
on: | |
push: | |
tags: | |
# Only build and deploy when a new tag is created matching a semantic version. | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
npm install | |
- name: Create .env file | |
run: | | |
echo AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} >> .env | |
echo AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} >> .env | |
echo AWS_DEFAULT_REGION=${{ secrets.AWS_REGION }} >> .env | |
echo NUXT_PUBLIC_GDOC_ENV=prod >> .env | |
- name: Build Nuxt.js application | |
run: | | |
npm run build | |
- name: Create a temporary directory for deployment artifacts | |
run: | | |
mkdir -p dist | |
- name: Copy generated files to dist directory | |
run: | | |
cp -r .output/* dist/ | |
- name: Stop gstream service | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOSTNAME }} | |
username: ec2-user | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: sudo systemctl stop gstream.service | |
- name: Remove existing deployment | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOSTNAME }} | |
username: ec2-user | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: sudo rm -rf /var/www/gstream/* | |
- name: scp dist to host | |
uses: garygrossgarten/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOSTNAME }} | |
username: ec2-user | |
privateKey: ${{ secrets.SSH_PRIVATE_KEY }} | |
local: dist | |
remote: /var/www/gstream/ | |
- name: Restart service | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOSTNAME }} | |
username: ec2-user | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
sudo systemctl daemon-reload | |
sudo systemctl start gstream.service | |
sudo systemctl enable gstream.service |