Fix/blog #1
This file contains hidden or 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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build-test-push: | |
| runs-on: ubuntu-latest | |
| services: | |
| mongo: | |
| image: mongo:6.0 | |
| ports: | |
| - 27017:27017 | |
| options: >- | |
| --health-cmd "mongosh --eval 'db.adminCommand('ping')'" --health-interval 10s --health-timeout 5s --health-retries 5 | |
| env: | |
| MONGODB_URI: mongodb://localhost:27017/cleanarchdb | |
| JWT_SECRET: test_jwt_secret | |
| PORT: 5000 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Lint | |
| run: yarn lint | |
| - name: Format | |
| run: yarn format | |
| - name: Run tests | |
| run: yarn test | |
| - name: Build Docker image | |
| run: docker build -t maebrie2017/clean-arch-app:latest . | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Push Docker image | |
| run: | | |
| IMAGE=maebrie2017/clean-arch-app | |
| docker tag $IMAGE:latest $IMAGE:${{ github.sha }} | |
| docker push $IMAGE:latest | |
| docker push $IMAGE:${{ github.sha }} |