From 24de77657ae49f79dfc5517d31232a153d33f805 Mon Sep 17 00:00:00 2001 From: proffapt Date: Sun, 30 Jun 2024 15:31:29 +0530 Subject: [PATCH] feat: added dockerhub push and pull stages --- .github/workflows/deploy.yaml | 42 +++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 877bc2b..90fb9a8 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -8,11 +8,39 @@ on: - "**.md" - "LICENSE" - "LICENSE.txt" - - ".gitignore" + - "frontend/**" jobs: + dockerhub: + name: Publish Docker Image(s) to Dockerhub + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + 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: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build & Push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/CONTAINER_NAME:latest + push: - name: Push Stage + name: Push Code Stage + needs: dockerhub runs-on: ubuntu-latest steps: @@ -32,13 +60,13 @@ jobs: sudo git fetch origin sudo git reset --hard origin/main - build: - name: Build Stage + pull: + name: Pull Image Stage needs: push runs-on: ubuntu-latest steps: - - name: Build the latest container(s) + - name: Pull the latest images(s) uses: appleboy/ssh-action@master env: PROJECT_DIR: ${{ secrets.PROJECT_DIR }} @@ -51,11 +79,11 @@ jobs: script_stop: true script: | cd "${PROJECT_DIR}/" - sudo docker compose build + sudo docker compose pull deploy: name: Deploy Stage - needs: [push, build] + needs: pull runs-on: ubuntu-latest steps: