Merge pull request #101 from KCY-Fit-a-Pet/fix/100 #26
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: Continuous Deployment | |
on: | |
push: | |
branches: ["develop"] | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: "Log level" | |
required: true | |
default: "warning" | |
type: choice | |
options: | |
- info | |
- warning | |
- error | |
environment: | |
description: "Environment" | |
required: false | |
type: environment | |
permissions: | |
contents: read | |
jobs: | |
continuous-deployment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Build Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew -version | |
./gradlew build --stacktrace --info -x test | |
shell: bash | |
- name: docker image build & push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_NICKNAME }}/fitapet:latest . | |
docker push ${{ secrets.DOCKER_NICKNAME }}/fitapet:latest | |
- name: Get Github Actions IP | |
id: ip | |
uses: haythem/[email protected] | |
- name: Setting NCP CLI & Credentials | |
run: | | |
cd ~ | |
wget https://www.ncloud.com/api/support/download/5/65 | |
unzip 65 | |
mkdir ~/.ncloud | |
echo -e "[DEFAULT]\nncloud_access_key_id = ${{ secrets.NCP_ACCESS_KEY }}\nncloud_secret_access_key = ${{ secrets.NCP_SECRET_KEY }}\nncloud_api_url = ${{ secrets.NCP_API_URL }}" >> ~/.ncloud/configure | |
- name: Add Github Action Ip to Security group | |
run: | | |
chmod -R 777 ~/cli_linux | |
cd ~/cli_linux | |
./ncloud vserver addAccessControlGroupInboundRule --regionCode KR --vpcNo ${{ secrets.NCP_VPC_NO }} --accessControlGroupNo ${{ secrets.NCP_AGC_NO }} --accessControlGroupRuleList "protocolTypeCode='TCP', ipBlock='${{ steps.ip.outputs.ipv4 }}/32', portRange='${{ secrets.SSH_PORT }}'" | |
- name: deploy | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
port: ${{ secrets.SSH_PORT }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
username: ${{ secrets.SSH_USERNAME }} | |
script: | | |
./start.sh | |
- name: Remove Github Action Ip to Security group | |
run: | | |
chmod -R 777 ~/cli_linux | |
cd ~/cli_linux | |
./ncloud vserver removeAccessControlGroupInboundRule --regionCode KR --vpcNo ${{ secrets.NCP_VPC_NO }} --accessControlGroupNo ${{ secrets.NCP_AGC_NO }} --accessControlGroupRuleList "protocolTypeCode='TCP', ipBlock='${{ steps.ip.outputs.ipv4 }}/32', portRange='${{ secrets.SSH_PORT }}'" |