Update build.yml
This commit is contained in:
77
.github/workflows/build.yml
vendored
77
.github/workflows/build.yml
vendored
@@ -7,18 +7,17 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
env:
|
env:
|
||||||
APP_NAME: desa-darmasaba
|
APP_NAME: desa-darmasaba
|
||||||
WA_PHONE: 6289697338821
|
WA_PHONE: "6289697338821,6289697338822"
|
||||||
EMAIL_FROM: bip.production.js@gmail.com
|
EMAIL_FROM: bip.production.js@gmail.com
|
||||||
EMAIL_TO: kurosakiblackangel@gmail.com
|
EMAIL_TO: "kurosakiblackangel@gmail.com,bip.production.ts@gmail.com"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Menjalankan PostgreSQL sebagai service di GitHub Actions
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:14
|
image: postgres:14
|
||||||
env:
|
env:
|
||||||
@@ -41,7 +40,10 @@ jobs:
|
|||||||
# Kirim notifikasi ke API build Start
|
# Kirim notifikasi ke API build Start
|
||||||
- name: Notify start build
|
- name: Notify start build
|
||||||
run: |
|
run: |
|
||||||
curl -X GET "https://wa.wibudev.com/code?text=build-start-${{ env.APP_NAME }}&nom=${{ env.WA_PHONE }}"
|
IFS=',' read -ra PHONES <<< "${{ env.WA_PHONE }}"
|
||||||
|
for PHONE in "${PHONES[@]}"; do
|
||||||
|
curl -X GET "https://wa.wibudev.com/code?text=build-start-${{ env.APP_NAME }}&nom=$PHONE"
|
||||||
|
done
|
||||||
|
|
||||||
# Checkout kode sumber
|
# Checkout kode sumber
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -51,6 +53,15 @@ jobs:
|
|||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
|
|
||||||
|
# Cache dependencies
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .bun
|
||||||
|
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lockb') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-bun-
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install
|
run: bun install
|
||||||
@@ -63,7 +74,7 @@ jobs:
|
|||||||
echo "NEXT_PUBLIC_WIBU_URL=${{ secrets.NEXT_PUBLIC_WIBU_URL }}" >> .env
|
echo "NEXT_PUBLIC_WIBU_URL=${{ secrets.NEXT_PUBLIC_WIBU_URL }}" >> .env
|
||||||
echo "WIBU_UPLOAD_DIR=${{ secrets.WIBU_UPLOAD_DIR }}" >> .env
|
echo "WIBU_UPLOAD_DIR=${{ secrets.WIBU_UPLOAD_DIR }}" >> .env
|
||||||
|
|
||||||
# create log file
|
# Create log file
|
||||||
- name: Create log file
|
- name: Create log file
|
||||||
run: touch build.txt
|
run: touch build.txt
|
||||||
|
|
||||||
@@ -109,35 +120,37 @@ jobs:
|
|||||||
source: ".env"
|
source: ".env"
|
||||||
target: "/var/www/projects/${{ env.APP_NAME }}/releases/${{ env.APP_VERSION }}/"
|
target: "/var/www/projects/${{ env.APP_NAME }}/releases/${{ env.APP_VERSION }}/"
|
||||||
|
|
||||||
# Kirim notifikasi ke API jika build berhasil
|
# Step 4: Set BUILD_STATUS based on success or failure
|
||||||
- name: Notify build success via API
|
- name: Set BUILD_STATUS
|
||||||
if: success()
|
if: success()
|
||||||
run: |
|
run: echo "BUILD_STATUS=success" >> $GITHUB_ENV
|
||||||
curl -X GET "https://wa.wibudev.com/code?text=finish-success-build-${{ env.APP_NAME }}&nom=6289697338821"
|
|
||||||
|
|
||||||
# Kirim notifikasi ke API jika build gagal
|
- name: Set BUILD_STATUS on failure
|
||||||
- name: Notify build failed via API
|
|
||||||
if: failure()
|
if: failure()
|
||||||
|
run: echo "BUILD_STATUS=failed" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Update status log
|
||||||
|
- name: Update status log
|
||||||
run: |
|
run: |
|
||||||
curl -X GET "https://wa.wibudev.com/code?text=finish-failed-build-${{ env.APP_NAME }}&nom=6289697338821"
|
echo "=====================" >> build.txt
|
||||||
|
echo "BUILD_STATUS=${{ env.BUILD_STATUS }}" >> build.txt
|
||||||
|
echo "APP_NAME=${{ env.APP_NAME }}" >> build.txt
|
||||||
|
echo "APP_VERSION=${{ env.APP_VERSION }}" >> build.txt
|
||||||
|
echo "LOG_URL=${{ env.LOG_URL }}" >> build.txt
|
||||||
|
echo "=====================" >> build.txt
|
||||||
|
|
||||||
# Send email with GitHub Actions logs
|
# Upload log to 0x0.st
|
||||||
- name: Send email with logs
|
- name: Upload log to 0x0.st
|
||||||
uses: dawidd6/action-send-mail@v3
|
id: upload_log
|
||||||
with:
|
run: |
|
||||||
server_address: smtp.gmail.com
|
LOG_URL=$(curl -F "file=@build.txt" https://0x0.st)
|
||||||
server_port: 587
|
echo "LOG_URL=$LOG_URL" >> $GITHUB_ENV
|
||||||
username: ${{ secrets.GMAIL_USERNAME }}
|
|
||||||
password: ${{ secrets.GMAIL_APP_PASSWORD }}
|
|
||||||
subject: "GitHub Actions Logs"
|
|
||||||
body: |
|
|
||||||
The deployment process has completed successfully.
|
|
||||||
|
|
||||||
Repository: ${{ github.repository }}
|
# Kirim notifikasi ke API
|
||||||
Branch: ${{ github.ref }}
|
- name: Notify build success via API
|
||||||
Commit: ${{ github.sha }}
|
run: |
|
||||||
|
IFS=',' read -ra PHONES <<< "${{ env.WA_PHONE }}"
|
||||||
to: ${{ env.EMAIL_TO }}
|
for PHONE in "${PHONES[@]}"; do
|
||||||
from: ${{ env.EMAIL_FROM }}
|
ENCODED_TEXT=$(bun -e "console.log(encodeURIComponent('Build-${{ env.BUILD_STATUS }}-${{ env.APP_NAME }}-Version-${{ env.APP_VERSION }}-Log:${{ env.LOG_URL }}'))")
|
||||||
attachments: |
|
curl -X GET "https://wa.wibudev.com/code?text=$ENCODED_TEXT&nom=$PHONE"
|
||||||
build.txt
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user