Skip to content

Deploy to Librarease frontend by @agmmtoo #162

Deploy to Librarease frontend by @agmmtoo

Deploy to Librarease frontend by @agmmtoo #162

Workflow file for this run

run-name: Deploy to Librarease frontend by @${{ github.actor }}
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
Build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- 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: ${{ secrets.AWS_REGION }}
# - name: export secret key
# run: |
# echo "${{ vars.production_ENV }}" > .env
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: "true"
# This is a separate action that sets up buildx runner
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
# Use Github action cache
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.REPOSITORY }}
IMAGE_TAG: ${{ vars.IMAGE_TAG }}
NEXT_PUBLIC_APP_URL: ${{ vars.NEXT_PUBLIC_APP_URL }}
run: |
docker build \
--build-arg NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
deploy-frontend-service:
name: Deploy to Frontend Service
runs-on: ubuntu-latest
needs: Build
steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Echo Branch
run: echo running on branch ${GITHUB_REF##*/}
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_SERVER_IP }}
username: ${{ secrets.PROD_SERVER_USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.PROD_SERVER_SSH_KEY }}
script: |
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/action
cd /home/ubuntu/deploy
bash deploy.sh