-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: EC2 Deploy | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Create necessary directories | ||
run: | | ||
mkdir -p infra/infra-redis/src/main/resources | ||
mkdir -p infra/infra-security/src/main/resources | ||
mkdir -p infra/infra-s3/src/main/resources | ||
mkdir -p data/src/main/resources | ||
- name: Create application-properties.yml | ||
run: | | ||
echo "${{ secrets.APPLICATION_REDIS }}" > infra/infra-redis/src/main/resources/application-redis.yml | ||
echo "${{ secrets.APPLICATION_SECURITY }}" > infra/infra-security/src/main/resources/application-security.yml | ||
echo "${{ secrets.APPLICATION_S3 }}" > infra/infra-s3/src/main/resources/application-s3.yml | ||
echo "${{ secrets.APPLICATION_RDB }}" > data/src/main/resources/application-rdb.yml | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build the Docker image | ||
run: docker build -t ${{ secrets.DOCKERHUB_REPOSITORY }}/kiwing-server:latest . | ||
|
||
- name: Docker Push | ||
run: docker push ${{ secrets.DOCKERHUB_REPOSITORY }}/kiwing-server:latest | ||
|
||
- name: Trigger Portainer Webhook | ||
run: | | ||
PORTAINER_WEBHOOK_URL=${{ secrets.PORTAINER_WEBHOOK_DNS }} | ||
curl -X POST -d "{}" -H "Content-Type: application/json" --insecure $PORTAINER_WEBHOOK_URL |