Merge remote-tracking branch 'origin/refactor/convention' into deploy… #292
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: Docker CI/CD | |
on: | |
push: | |
branches: | |
- deploy/production | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v2 | |
# - name: Set up Docker Buildx | |
# uses: docker/setup-buildx-action@v2 | |
- name: 📦️ Setup JDK 11.0.12 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11.0.12 | |
- name: 💾 Cache Gradle & Spring | |
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: make apple Login KEY | |
run: | | |
cd ./src/main/resources/static/apple | |
touch ./AuthKey_2Q827DJQSK.p8 | |
echo "${{ secrets.APPLE_KEY }}" > ./AuthKey_2Q827DJQSK.p8 | |
shell: bash | |
- name: make application-db.properties | |
run: | | |
cd ./src/main/resources | |
touch ./application-db.properties | |
echo "${{ secrets.DB_PROPERTIES }}" > ./application-db.properties | |
shell: bash | |
- name: make application-real.properties | |
run: | | |
cd ./src/main/resources | |
touch ./application-real.properties | |
echo "${{ secrets.REAL_PROPERTIES }}" > ./application-real.properties | |
shell: bash | |
- name: make application-oauth.properties | |
run: | | |
cd ./src/main/resources | |
touch ./application-oauth.properties | |
echo "${{ secrets.OAUTH_PROPERTIES }}" > ./application-oauth.properties | |
shell: bash | |
- name: create-json | |
id: create-json | |
uses: jsdaniell/create-json@v1.2.2 | |
with: | |
name: "fireBaseAccountKey.json" | |
json: ${{ secrets.FIREBASEKEY }} | |
dir: './src/main/resources' | |
- name: 🔧 Build Spring server | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
# - name: Build Docker image | |
# uses: docker/build-push-action@v2 | |
# with: | |
# context: . | |
# outputs: type=docker,dest=./sinzak-backend.tar | |
# push: false | |
# tags: sinzak:latest | |
- name: Deploy Prod use SCP | |
uses: appleboy/scp-action@master | |
with: | |
username: ec2-user | |
host: ${{ secrets.HOST_DEV }} | |
key: ${{ secrets.SSH_PEM_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
# source: "./sinzak-backend.tar" | |
source: "./build/libs/*.jar" | |
target: "/home/ec2-user/deploy" | |
strip_components: 2 | |
- name: Execute Server Init Script | |
uses: appleboy/ssh-action@master | |
id: deploy-prod | |
with: | |
host: ${{ secrets.HOST_DEV }} | |
username: ec2-user | |
key: ${{ secrets.SSH_PEM_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
port: 22 | |
envs: GITHUB_SHA | |
script: | | |
cd deploy | |
docker container stop sinzak | |
docker container stop redis | |
docker build -t sinzak . | |
docker-compose up -d |