add pnpm version #22
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 to production | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Docker image build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20.17.0" | |
- name: Setup pnpm and dependencies | |
uses: pnpm/action-setup@v4 | |
with: | |
version: '9.12.1' | |
- name: Login to docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build docker image | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/codium-website \ | |
--build-arg BASE_URL=${{ secrets.BASE_URL }} \ | |
--target=production . | |
- name: Push docker image to Docker Hub | |
run: docker push ${{ secrets.DOCKER_USERNAME }}/codium-website:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
name: Deployment | |
steps: | |
- name: Deploy using SSH | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
port: 22 | |
script: | | |
cd codium-website; | |
docker stop codium-website; | |
docker rm codium-website; | |
docker pull ${{ secrets.DOCKER_USERNAME }}/codium-website:latest; | |
docker run --restart always -d -p 8000:8000 --name codium-website ${{ secrets.DOCKER_USERNAME }}/codium-website:latest |