-
Notifications
You must be signed in to change notification settings - Fork 0
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
CI/CD Pipeline Construction #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: CI for Pull Request Test | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
CI: | ||
runs-on: ubuntu-latest | ||
env: | ||
CI: true | ||
steps: | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
# Gradle caching | ||
- name: Gradle Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
|
||
- name: Create application-prod.yml file | ||
run: | | ||
mkdir -p ./src/main/resources | ||
touch ./src/main/resources/application-prod.yml | ||
echo "${{ secrets.APPLICATION_PROD }}" > ./src/main/resources/application-prod.yml | ||
cat ./src/main/resources/application-prod.yml | ||
|
||
# Gradle build | ||
- name: Build with Gradle | ||
run: ./gradlew build -x test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: CI/CD using GitHub Actions & Docker | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
CI-CD: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Create directory and file if not exist | ||
run: | | ||
mkdir -p ./src/main/resources | ||
echo "${{ secrets.APPLICATION_PROD }}" > ./src/main/resources/application-prod.yml | ||
|
||
- name: Set executable permission | ||
run: chmod +x ./gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew bootJar | ||
|
||
- name: Docker build & push to prod | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/spaced:0.0.1-SNAPSHOT . | ||
docker push ${{ secrets.DOCKER_USERNAME }}/spaced:0.0.1-SNAPSHOT | ||
|
||
- name: Deploy to prod | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST_PROD }} | ||
username: ubuntu | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
Comment on lines
+38
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ง๋ฌธ ๐ฌSelf Hosted Runner ๊ฐ์๊ฑธ ์ฌ์ฉํ ์๋ ์์ผ์ จ์ํ ๋ฐ , ssh-action์ ์ฌ์ฉํด AWS ํค๋ก ์ธ๋ถ์์ ์ ์ํด CD ๊ณผ์ ์ ์งํํ๋ ๋ฐฉ์์ ์ ํํ์ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํฐ ์ด์ ๋ ์๊ณ AWS ํค๋ฅผ ์ฌ์ฉํ์ฌ ํน์ ์๋ฒ์๋ง ์ ๊ทผํ ์ ์๋๋ก ์ค์ ํ์ต๋๋ค. |
||
envs: GITHUB_SHA | ||
script: | | ||
sudo docker stop spaced | ||
sudo docker rm spaced | ||
sudo docker rmi ${{ secrets.DOCKER_USERNAME }}/spaced:0.0.1-SNAPSHOT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ง๋ฌธ ๐ฌpull ์ ์ ์ด๋ฏธ์ง๋ฅผ ์ญ์ ํ๋๊น ๊ด์ฐฎ์ ๊ฒ ๊ฐ๊ธฐ๋ ํ๋ฐ...ํน์ ๋ชฐ๋ผ์ ๋๊ธ๋ง ์ด๋ฏธ์ง๋ฅผ ์ ๊ฒฝ ์ฐ์ง ์์๋ ๊ด์ฐฎ์์ง ์ง๋ฌธ ๋๋ฆฝ๋๋ค There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ์ฌ ์ค์ ์์๋ ์ด๋ฏธ์ง๋ฅผ pullํ๊ธฐ ์ ์ ๊ธฐ์กด ์ด๋ฏธ์ง๋ฅผ ์ญ์ ํ๊ณ ์์ด ๋๊ธ๋ง ์ด๋ฏธ์ง๊ฐ ๋จ์ง ์๋๋ก ๊ด๋ฆฌํ๊ณ ์์ต๋๋ค. |
||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/spaced:0.0.1-SNAPSHOT | ||
sudo docker run -d -p 8080:8080 --name spaced ${{ secrets.DOCKER_USERNAME }}/spaced:0.0.1-SNAPSHOT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ํ ๐
๊น๋จน์๊น๋ด ์ ํ์ผ๋ก ๋จ๊ฒผ๊ณ ์ ์ฉํ์ง ์์๋ ๊ด์ฐฎ์ต๋๋ค
๋์ปค ์ด๋ฏธ์ง ํ๊ทธ ๊ฐ์ ๋ถ๋ถ์ ๋์ค์ ๋ฆด๋ฆฌ์ฆ ๊ด๋ฆฌ๋ฅผ ํ๋ค๊ณ ํ๋ฉด ๋ณ๊ฒฝํด์ผ ํ ๊ฒ ๊ฐ๊ธฐ๋ ํฉ๋๋ค
๋ค๋ง ๋ฆด๋ฆฌ์ฆ ๊ด๋ฆฌ ์์ฒด์ ๋ํ ์ปจ๋ฒค์ ์ ์ ์ ํ์ผ๋ ๊ทธ๋๋ก ์งํํ๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ค, ํ์ฌ๋ ๊ฐ๋จํ ๋ฐฐํฌ๋ฅผ ์๋ํํ๋ ๋ฐ ์ด์ ์ ๋ง์ถ์์ต๋๋ค. ์ถํ ๋ฆด๋ฆฌ์ฆ ๊ด๋ฆฌ ์ปจ๋ฒค์ ์ ๋์ ํ ๋ ์ด๋ฏธ์ง ํ๊ทธ ๊ด๋ฆฌ๋ฅผ ํจ๊ป ๊ฐ์ ํ๋๋ก ํ๊ฒ ์ต๋๋ค.