Skip to content

Commit

Permalink
feat: Fix workflow when pulling docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
trianggianggara committed Jul 11, 2024
1 parent d137d09 commit 8290bce
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,33 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Decode and save .env file
run: |
echo ${{ secrets.ENV_FILE }} | base64 -d > .env
echo ${{ secrets.ENV_FILE_DEVELOPMENT }} | base64 -d > .env.development
- name: Decode and save .env file
run: |
echo ${{ secrets.ENV_FILE }} | base64 -d > .env
echo ${{ secrets.ENV_FILE_DEVELOPMENT }} | base64 -d > .env.development
- name: Build and Push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.IMAGE_NAME }}:latest
- name: Build and Push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
deploy:
runs-on: ubuntu-latest
Expand All @@ -63,7 +65,7 @@ jobs:
- name: Deploy via SSH
uses: appleboy/[email protected]
env:
ENV: ${{ secrets.ENV}}
ENV: ${{ secrets.ENV }}
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
Expand All @@ -72,7 +74,8 @@ jobs:
envs: ENV
script: |
cd /home/trianggianggara23/app/gh5-backend
git pull github main
docker compose -f docker-compose.yml down
docker compose -f docker-compose.yml up -d
git pull origin main
docker compose down
docker compose pull
docker compose up -d
docker image prune -f

0 comments on commit 8290bce

Please sign in to comment.