diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a9b6cdf..31633b3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,90 +1,48 @@ -# Goal - I have to Lint, Build, Test the code for Frontend & Backend -# then Push the images to DockerHub +# Goal: Build the image for devboard frontend and push to docker hub name: CI on: - push: - branches: [master] + push: + branches: [master] jobs: - frontend: - # Github runner - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v7 + code-lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Set up Node js + uses: actions/setup-node@v4 + with: + node-version: 24 + + - name: Install node.js dependecies + working-directory: frontend + run: npm ci + + - name: Run ESLint + working-directory: frontend + run: npm run lint + + build-and-push: + needs: code-lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Docker setup [Login to Docker] + uses: docker/login-action@v4 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Docker Build and Push + uses: docker/build-push-action@v7 + with: + context: frontend + file: frontend/Dockerfile + push: true + tags: ${{ vars.DOCKERHUB_USERNAME }}/devboard-fe-master:latest - - name: Setup NodeJs - uses: actions/setup-node@v6 - with: - node-version: '20' - cache: npm - cache-dependency-path: frontend/package-lock.json - - - name: Install npm Packages - run: npm install - working-directory: frontend - - - name: Run Linter - run: npm run lint - working-directory: frontend - - - name: Run Tests - run: npm run test - working-directory: frontend - - - name: Docker Setup [Login] - uses: docker/login-action@v4 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Docker Build and Push - uses: docker/build-push-action@v7 - with: - context: ./frontend - push: true - tags: ${{ vars.DOCKERHUB_USERNAME }}/devboard-frontend:latest - - backend: - # Github runner - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v7 - - - name: Setup Go - uses: actions/setup-go@v6 - with: - go-version: '1.23' - go-version-file: 'go.mod' - cache-dependency-path: go.sum - - - name: Run Go Formatter - run: go fmt - working-directory: backend - - - name: Run Go Vet - run: go vet - working-directory: backend - - - name: Run Tests - run: go test - working-directory: backend - - - name: Docker Setup [Login] - uses: docker/login-action@v4 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Docker Build and Push - uses: docker/build-push-action@v7 - with: - context: ./backend - push: true - tags: ${{ vars.DOCKERHUB_USERNAME }}/devboard-backend:latest - deploy: - needs: [frontend,backend] - uses: ./.github/workflows/cd.yml - secrets: inherit