feat: cd μμ± #1
Workflow file for this run
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/CD Pipeline with Gradle and Docker | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: # TODO: ν μ€νΈμ©, mergeμ μμ νκΈ° | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Github Actions IP | |
id: ip | |
uses: haythem/[email protected] | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Add Github Actions IP to Security group | |
run: | | |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
## create application-database.yaml -> TODO: DB μ°λν λ νμ±ν, submodule μ¬μ© | |
# - name: make application-database.yaml | |
# run: | | |
# ## create application-database.yaml | |
# cd ./src/main/resources | |
# | |
# # application-database.yaml νμΌ μμ± | |
# touch ./application-database.yaml | |
# | |
# # GitHub-Actions μμ μ€μ ν κ°μ application-database.yaml νμΌμ μ°κΈ° | |
# echo "${{ secrets.DATABASE }}" >> ./application-database.yaml | |
# shell: bash | |
- name: Build with Gradle | |
run: ./gradlew bootJar | |
- name: web docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_REPO }}/fiesta-web . | |
docker push ${{ secrets.DOCKER_REPO }}/fiesta-web | |
## docker compose up | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
sudo docker rm -f $(docker ps -qa) | |
sudo docker pull ${{ secrets.DOCKER_REPO }}/fiesta-web | |
docker-compose up -d | |
docker image prune -f | |
- name: Remove Github Actions IP From Security Group | |
run: | | |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 |