Skip to content

Illegal state investigation #91

Illegal state investigation

Illegal state investigation #91

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: CI/CD
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
env:
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}
TELEGRAM_USERNAME: ${{ secrets.TELEGRAM_USERNAME }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
jobs:
test:
name: Testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run Tests
run: gradle test
- name: Generate Coverage Report
run: gradle jacocoTestReport
analyze:
name: Analysing
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
arguments: build sonar --info -Dsonar.working.directory=.scannerwork -Dsonar.projectKey=jazzman_odmiana -Dsonar.organization=jazzman -Dsonar.host.url=https://sonarcloud.io
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
# Force to fail step after specific time.
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build:
name: Building
needs: analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build -x test
- name: Build and Push Docker Image
uses: mr-smithers-excellent/docker-build-push@v5
with:
image: ${{ secrets.DOCKER_USERNAME }}/odmiana
tags: ${{ github.sha }}
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
deploy:
name: Deploying
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to AWS EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
docker login
docker pull ${{ secrets.DOCKER_USERNAME }}/odmiana:${{ github.sha }}
docker stop odmiana
docker rm odmiana
docker run --detach --name odmiana --network ec2-user_odmiana_network -e MONGO_HOST -e MONGO_USERNAME -e MONGO_PASSWORD -e TELEGRAM_USERNAME -e TELEGRAM_TOKEN -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/odmiana:${{ github.sha }}