====== Integración y despliegue continuo de una aplicación ======
{{ github_actions_logo.png?200 }}
===== Testing ====== Workflow: **Node.js** name: Unit and integration tests on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-20.04 strategy: matrix: node-version: [18.x, 20.x, 22.x] steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm install - run: docker compose -f docker-compose.dev.yaml up -d - run: sleep 3 - run: npm run unit-test - run: npm run integration-test ===== Crear una imagen docker ====== Workflow: **Docker Image** name: Docker Image CI on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build the Docker image run: docker build . --file Dockerfile --tag cities:$(date +%s) ===== Publicar una imagen docker en Docker Hub ====== Workflow: **Publish Docker Image** name: Publish docker image on: push: branches: - main jobs: publish-docker-image: runs-on: ubuntu-latest steps: - uses: docker/login-action@v4 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} - uses: actions/checkout@master - uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '21' - run: mvn package - run: docker build -t sfaci/games . - run: docker compose up -d - run: npm install -g newman - run: newman run games.postman_collection.json -e local.postman_environment.json - run: docker push sfaci/games ===== Lanzar un análisis de código con Sonarqube ====== Workflow: **SonarQube** name: Sonarqube on: push: branches: - main pull_request: types: [opened, synchronize, reopened] jobs: sonarqube: name: SonarQube runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarQube Scan uses: SonarSource/sonarqube-scan-action@v5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} ---- (c) 2024 Santiago Faci