Skip to content

chore(deps): bump @vueuse/core from 12.1.0 to 12.2.0 in /web #664

chore(deps): bump @vueuse/core from 12.1.0 to 12.2.0 in /web

chore(deps): bump @vueuse/core from 12.1.0 to 12.2.0 in /web #664

Workflow file for this run

name: deploy
on:
push:
branches:
- main
pull_request:
types:
- labeled
concurrency:
group: deploy-main
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
checks: read
statuses: read
actions: read
repository-projects: read
jobs:
terraform:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'deploy' && github.actor == 'crlssn')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create SSH file
run: |
mkdir ~/.ssh
echo "${{ secrets.AWS_EC2_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Set up terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform Init
run: terraform init
working-directory: ./infrastructure
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Terraform Apply
run: terraform apply -auto-approve
working-directory: ./infrastructure
env:
# TF_LOG: DEBUG
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VAR_db_username: ${{ secrets.DB_USER }}
TF_VAR_db_password: ${{ secrets.DB_PASSWORD }}
database:
needs: terraform
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install golang-migrate
run: |
wget https://github.com/golang-migrate/migrate/releases/latest/download/migrate.linux-amd64.deb
sudo dpkg -i migrate.linux-amd64.deb
- name: Run migration
env:
DB_HOST: ${{ vars.DB_HOST }}
DB_PORT: ${{ vars.DB_PORT }}
DB_NAME: ${{ vars.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: |
migrate -path database/migrations/ \
-database "postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}" \
-verbose up
server:
needs: database
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build binary
working-directory: ./server
run: |
go mod download
GOOS=linux go build -o bin/app cmd/main.go
- name: Create env file
working-directory: ./server/bin
run: |
{
echo DB_HOST=${{ vars.DB_HOST }}
echo DB_PORT=${{ vars.DB_PORT }}
echo DB_USER=${{ vars.DB_USER }}
echo DB_PASSWORD=${{ secrets.DB_PASSWORD }}
echo DB_NAME=${{ vars.DB_NAME }}
echo CORS_ALLOWED_ORIGIN=${{ vars.CORS_ALLOWED_ORIGIN }}
echo SERVER_PORT=${{ vars.SERVER_PORT }}
echo SERVER_CERT_PATH=${{ vars.SERVER_CERT_PATH }}
echo SERVER_KEY_PATH=${{ vars.SERVER_KEY_PATH }}
echo COOKIE_DOMAIN=${{ vars.COOKIE_DOMAIN }}
echo JWT_ACCESS_TOKEN_KEY=${{ secrets.JWT_ACCESS_TOKEN_KEY }}
echo JWT_REFRESH_TOKEN_KEY=${{ secrets.JWT_REFRESH_TOKEN_KEY }}
} >> .env
- name: Deploy to EC2
uses: easingthemes/[email protected]
with:
REMOTE_HOST: ${{ vars.AWS_EC2_REMOTE_HOST }}
REMOTE_USER: 'ec2-user'
SSH_PRIVATE_KEY: ${{ secrets.AWS_EC2_PRIVATE_KEY }}
SOURCE: 'server/bin/'
- name: Export AWS credentials
uses: appleboy/[email protected]
with:
host: ${{ vars.AWS_EC2_REMOTE_HOST }}
username: 'ec2-user'
key: ${{ secrets.AWS_EC2_PRIVATE_KEY }}
port: 22
script: |
echo "export AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}"
echo "export AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}"
- name: Restart service
uses: appleboy/[email protected]
with:
host: ${{ vars.AWS_EC2_REMOTE_HOST }}
username: 'ec2-user'
key: ${{ secrets.AWS_EC2_PRIVATE_KEY }}
port: 22
script: |
cd /home/ec2-user
sudo systemctl restart app.service
web:
needs: server
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
working-directory: ./web
run: npm install
- name: Build the app
working-directory: ./web
run: npm run build
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Deploy to S3
working-directory: ./web
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_BUCKET_NAME: ${{ vars.AWS_BUCKET_NAME }}
run: |
# Sync the build folder to the S3 bucket
aws s3 sync ./dist "s3://$AWS_BUCKET_NAME" --delete
# Make sure the S3 bucket content is accessible publicly
aws s3 website "s3://$AWS_BUCKET_NAME/" --index-document index.html --error-document index.html
cleanup:
needs: [terraform, database, server, web]
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Remove deploy label
if: github.event_name == 'pull_request' && github.event.label.name == 'deploy'
run: gh pr edit ${{ github.event.pull_request.number }} --remove-label "deploy"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}