Skip to content

Merge pull request #131 from ITZipProject/main #6

Merge pull request #131 from ITZipProject/main

Merge pull request #131 from ITZipProject/main #6

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "release" ]
jobs:
build:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
steps:
- uses: actions/checkout@v3
- name: Login Dockerhub
env:
DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}}
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- name: make .env
run: |
touch .env
echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" >> .env
echo "${{ secrets.SECRET_ENV}}" >> .env
- name: Builder the Docker image
run: docker build --build-arg NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }} -t ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2 .
- name: taging
run: docker tag ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2 ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2:latest
- name: Push to Dockerhub
run: docker push ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2:latest
- name: executing remote ssh commands using ssh key
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: 22
script: |
echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" > /home/ubuntu/itzip/.env
docker-compose -f /home/ubuntu/itzip/docker-compose.yml down
docker-compose -f /home/ubuntu/itzip/docker-compose.yml pull
docker-compose -f /home/ubuntu/itzip/docker-compose.yml up -d
docker system prune -a -f