Merge pull request #404 from Team-Ampersand/develop #38
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 CICD with Gradle | |
on: | |
pull_request: | |
branches: | |
- 'master' | |
push: | |
branches: | |
- 'master' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Create application.yml | |
run: | | |
touch ./src/main/resources/application.yml | |
echo "${{ secrets.APPLICATION_YML }}" >> ./src/main/resources/application.yml | |
- name: Create application-prod.yml | |
run: | | |
touch ./src/main/resources/application-dev.yml | |
echo "${{ secrets.APPLICATION_PROD_YML }}" >> ./src/main/resources/application-prod.yml | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Login Dockerhub | |
env: | |
DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} | |
DOCKER_PASSWORD: ${{secrets.DOCKERHUB_TOKEN}} | |
run: docker login -u ${{secrets.DOCKERHUB_USERNAME}} -p ${{secrets.DOCKERHUB_TOKEN}} | |
- name: Build the Docker image | |
run: docker build --platform linux/amd64 --build-arg DEPENDENCY=build/dependency -f DockerfileProd -t ${{secrets.DOCKERHUB_USERNAME}}/dotori-prod . | |
- name: Docker Push | |
run: docker push ${{secrets.DOCKERHUB_USERNAME}}/dotori-prod |