Skip to content

docs(contents): update my custom nas #64

docs(contents): update my custom nas

docs(contents): update my custom nas #64

name: build-and-deploy
on:
push:
pull_request:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: main
- name: install package manager
run: |
npm i -g pnpm
- name: docker login
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login ${{ secrets.DOCKER_REGISTRY }} --username=${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: build docker image
run: |
docker build . \
--build-arg NEXT_PUBLIC_HELLO=hello \
--build-arg NEXT_PUBLIC_WORLD=world \
--build-arg NEXT_PUBLIC_HELLO_WORLD=${{ secrets.HELLO_WORLD }} \
--build-arg HELLO_WORLD=${{ secrets.HELLO_WORLD }} \
--file Dockerfile \
--tag ${{ secrets.DOCKER_IMAGE }}
- name: publish docker image
run: |
docker push ${{ secrets.DOCKER_IMAGE }}
- name: docker logout
run: |
docker logout
- name: deploy to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login ${{ secrets.DOCKER_REGISTRY }} --username=${{ secrets.DOCKER_USERNAME }} --password-stdin
docker pull ${{ secrets.DOCKER_IMAGE }}
docker stop ${{ secrets.DOCKER_CONTAINER }} || true
docker rm ${{ secrets.DOCKER_CONTAINER }} || true
docker run -d --name ${{ secrets.DOCKER_CONTAINER }} -p ${{ secrets.DOCKER_PORT }}:${{ secrets.DOCKER_PORT }} ${{ secrets.DOCKER_IMAGE }}
docker image prune -f
docker logout