Skip to content

Commit

Permalink
Merge pull request #7 from diegosneves/feature/ci-hlg
Browse files Browse the repository at this point in the history
👷 Adiciona arquivo da CI de HLG e atualiza CI de Produção
  • Loading branch information
diegosneves authored Apr 16, 2024
2 parents 9eeb0c6 + 802d64c commit 8d7c87b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 5 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/ci-hlg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

name: CI HLG

on:
pull_request: # Essas linhas indica que toda pull_request apontada para a branch main sera executado a CI
branches:
- 'release/*'
jobs:
check-application:
strategy:
matrix:
ubuntu: ['ubuntu-latest']
java: ['17']
runs-on: ${{ matrix.ubuntu }}

services:
mysql:
image: mysql:latest
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_PASSWORD }}
MYSQL_DATABASE: ${{ secrets.DB_NAME }}
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10

env:
DB_NAME: ${{ secrets.DB_NAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_HOST: 127.0.0.1
DB_PORT: 3306

steps:
- name: Checkout codigo
uses: actions/checkout@v3

- name: check PR head branch
run: |
if [[ "${{ github.head_ref }}" != develop ]]; then
echo "PRs to main must come from a develop branch. PR is from '${{ github.head_ref }}'"
exit 1
fi
- name: Get branch name
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/*/} | cut -d'/' -f2)" >> $GITHUB_ENV

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: ${{ matrix.java }}

- name: Setup Maven
run: |
sudo apt-get install -y maven
- name: Install Dependencies
run: mvn clean install -DskipTests

- name: Run Tests
run: mvn test

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
tags: diegoneves/clean-architecture:${{ env.BRANCH_NAME }}
build-args: |
DB_NAME=${{ env.DB_NAME }}
DB_PASSWORD=${{ env.DB_PASSWORD }}
DB_USERNAME=${{ env.DB_USERNAME }}
6 changes: 1 addition & 5 deletions .github/workflows/ci-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ jobs:
exit 1
fi
- name: Get branch name
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | cut -d'/' -f2)" >> $GITHUB_ENV

- name: Setup Java
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -78,7 +74,7 @@ jobs:
uses: docker/build-push-action@v4
with:
push: true
tags: diegoneves/clean-architecture:${{ env.BRANCH_NAME }}
tags: diegoneves/clean-architecture:latest
build-args: |
DB_NAME=${{ env.DB_NAME }}
DB_PASSWORD=${{ env.DB_PASSWORD }}
Expand Down

0 comments on commit 8d7c87b

Please sign in to comment.