Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: EC2 Instance, RDS Deploy & CD Pipeline #3

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CD

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}
submodules: true

- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

- name: Update Git submodules
run: git submodule update --remote --recursive

- name: Build and test with Gradle
run: ./gradlew test

- name: Build and push Docker image
run: ./gradlew clean bootBuildImage -PDOCKERHUB_ID=${{ secrets.DOCKERHUB_ID }} -PDOCKERHUB_TOKEN=${{ secrets.DOCKERHUB_TOKEN }}

- name: SSH into EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
password: ${{ secrets.EC2_PASSWORD }}
port: ${{ secrets.EC2_SSH_PORT }}
script: |
docker pull ${{ secrets.DEV_DOCKER_HUB_URL }}
docker ps -f name=be-server -q | xargs --no-run-if-empty docker container stop
docker ps -a -f name=be-server -q | xargs --no-run-if-empty docker container rm
docker run -d --name be-server -p 80:8080 ${{ secrets.DEV_DOCKER_HUB_URL }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: A11
name: CI

on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion A11-Config
Loading