Merge pull request #141 from OMZigak/release-v1.0.0 #17
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: prod-CD | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
ci: | |
runs-on: ubuntu-22.04 | |
env: | |
working-directory: . | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
token: ${{ secrets.SUBMODULE_TOKEN }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: build | |
run: | | |
chmod +x gradlew | |
./gradlew build -x test | |
shell: bash | |
- name: docker login | |
uses: docker/[email protected] | |
- name: login docker hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_LOGIN_USERNAME }} | |
password: ${{ secrets.DOCKER_LOGIN_ACCESSTOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile-prod | |
push: true | |
tags: ${{ secrets.DOCKER_LOGIN_USERNAME }}/${{ secrets.PROD_REPONAME }} | |
cd: | |
needs: ci | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: docker container run | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PROD_SERVER_IP }} | |
username: ${{ secrets.PROD_SERVER_USER }} | |
key: ${{ secrets.PROD_SERVER_KEY }} | |
script: | | |
cd ~ | |
./deploy.sh | |
create-release: | |
needs: cd | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 버전 정보 추출 | |
id: extract_version_name | |
run: | | |
VERSION=$(echo "${{ github.event.head_commit.message }}" | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -n1 | tr -d '[:space:]') | |
if [ -z "$VERSION" ]; then | |
echo "No version found in the commit message." | |
exit 1 | |
fi | |
- name: Create GitHub Release | |
run: | | |
response=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.SUBMODULE_TOKEN }}" \ | |
https://api.github.com/repos/OMZigak/KKUMER/releases \ | |
-d '{"tag_name":"${{ steps.extract_version_name.outputs.version }}","target_commitish":"main","name":"${{ steps.extract_version_name.outputs.version }}","generate_release_notes":true}') | |
if [ "$response" -ne 201 ]; then | |
echo "GitHub Release failed with status code $response" | |
exit 1 | |
fi |