Merge pull request #125 from ITZipProject/main #3
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 Image CI | |
on: | |
push: | |
branches: [ "release" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
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 "${{ secrets.SECRET_ENV}}" > .env | |
- name: Builder the Docker image | |
run: docker build -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: | | |
sudo docker-compose -f /home/ubuntu/itzip/docker-compose.yml down | |
sudo docker rmi itzip/ts-react-18-nextjs-14.2:latest | |
sudo docker-compose -f /home/ubuntu/itzip/docker-compose.yml up -d | |
sudo docker system prune -a -f |