feat: readMyGroups 추상화 #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: Deploy Frontend on Server via DockerHub | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main] | |
env: | |
HOST: ${{ secrets.HOST }} | |
USERNAME: ${{ secrets.USERNAME }} | |
KEY: ${{ secrets.SSH_KEY }} | |
PORT: ${{ secrets.PORT }} | |
INSTANCE_PATH: ./savemyreceipt-client | |
IMAGE_NAME: shinsion/savemyreceipt-client | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout source code | |
uses: actions/checkout@v4 | |
- name: Create Environment Variables | |
run: | | |
mkdir -p ./ | |
echo "${{ secrets.PRODUCTION_ENV }}" > ./.env.production | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Dockerhub login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get current date and commit SHA | |
id: vars | |
run: | | |
echo "DATE=$(date +%Y%m%d)" >> $GITHUB_ENV | |
echo "COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV | |
- name: Docker image build and push | |
run: | | |
docker buildx create --use | |
docker buildx build --platform linux/amd64,linux/arm64 -t ${{ env.IMAGE_NAME }}:${{ env.DATE }}-${{ env.COMMIT_SHA }} --push . | |
- name: Pull Docker image to Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ env.HOST }} | |
username: ${{ env.USERNAME }} | |
key: ${{ env.KEY }} | |
port: ${{ env.PORT }} | |
script: | | |
cd ${{ env.INSTANCE_PATH }} | |
docker stop savemyreceipt-client || true | |
docker rm savemyreceipt-client || true | |
docker rmi ${{ env.IMAGE_NAME }}:latest || true | |
docker pull ${{ env.IMAGE_NAME }}:${{ env.DATE }}-${{ env.COMMIT_SHA }} | |
docker tag ${{ env.IMAGE_NAME }}:${{ env.DATE }}-${{ env.COMMIT_SHA }} ${{ env.IMAGE_NAME }}:latest | |
docker compose up -d |