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

Create gradle.yml #43

Merged
merged 1 commit into from
Jan 12, 2024
Merged
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
60 changes: 60 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: hhive

on:
pull_request:
branches: [ dev ]
types: [closed]

jobs:
build-docker-image:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Build with Gradle
run: ./gradlew build

- name: web docker build and push
run: |
sudo docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
sudo docker build -f Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/hhive .
sudo docker push ${{ secrets.DOCKERHUB_USERNAME }}/hhive

- name: Deploy Front to prod
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_HOST }}
username: ubuntu
key: ${{ secrets.AWS_SSH_KEY }}
port: 22
script: |
if docker ps -a --format ‘{{.ID}}’ | grep -q .; then
sudo docker rm -f $(docker ps -qa)
else
echo “No Docker containers to remove.”
fi
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/hhive
sudo docker run --name hhive -d ${{ secrets.DOCKERHUB_USERNAME }}/hhive
sudo docker run --name redis-server -d -p 6379:6379 redis
docker image prune -f
Loading