Jungwoo/Complete #60
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: Docker CD | |
on: | |
push: | |
branches: | |
- 'production' | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- 'production' | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Make env | |
run: | | |
touch ./.env | |
echo "${{ secrets.ENV }}" > ./.env | |
echo .env | |
shell: sh | |
- name: Install dependencies | |
run: yarn | |
- name: Build Project | |
run: yarn build | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ secrets.DOCKER_USERNAME }}/home-appcenter | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
script: | | |
docker stop inu-hompage | |
docker rm inu-hompage | |
docker pull ${{ secrets.DOCKER_USERNAME }}/home-appcenter:production | |
docker run -d —name inu-hompage -p 3000:3000 ${{ secrets.DOCKER_USERNAME }}/home-appcenter:production | |
# docker image prune -f |