Repo for CI #1
This file contains 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: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
# pull_request: | |
# branches: [ "main" ] | |
pull_request_target: | |
types: [opened, reopened, synchronize, labeled] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: | | |
(github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') && | |
contains(github.event.pull_request.labels.*.name, 'CI') | |
services: | |
redis: | |
image: redis:latest | |
ports: | |
- 6379:6379 | |
# mongodb: | |
# image: mongo:latest | |
# ports: | |
# - 27017:27017 | |
# env: | |
# MONGO_INITDB_DATABASE: test | |
# MONGO_INITDB_ROOT_USERNAME: root | |
# MONGO_INITDB_ROOT_PASSWORD: 1231 | |
# zookeeper: | |
# image: confluentinc/cp-zookeeper:latest | |
# ports: | |
# - 2181:2181 | |
# kafka: | |
# image: confluentinc/cp-kafka:latest | |
# ports: | |
# - 9092:9092 | |
# depends_on: | |
# - zookeeper | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Set test yml | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ./src/test/resources/application.yml | |
env: | |
spring.security.jwt.secret: ${{ secrets.JWT_SECRET_KEY }} | |
spring.data.mongodb.uri: ${{ secrets.MONGO_TEST_URI }} | |
custom.domain.image.baseUrl: ${{ secrets.BASE_URL }} | |
cloud.aws.s3.bucket: ${{ secrets.S3_BUCKET_NAME }} | |
cloud.aws.region.static: ${{ secrets.S3_REGION }} | |
cloud.aws.credentials.accessKey: ${{ secrets.AWS_ACCESS_KEY }} | |
cloud.aws.credentials.secretKey: ${{ secrets.AWS_ACCESS_SECRET }} | |
- name: Run chmod to make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Docker Compose For Test | |
run: | | |
touch docker-compose.yml | |
echo "${{ secrets.CI_DOCKER_COMPOSE }}" > docker-compose.yml | |
echo docker-compose.yml | |
docker-compose up -d | |
- name: Test with Gradle | |
run: ./gradlew test |