50 lines
1.3 KiB
YAML
50 lines
1.3 KiB
YAML
name: Build dan Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
REGISTRY: 192.168.0.121:3000
|
|
IMAGE: 192.168.0.121:3000/sayudhalw/hello-ci
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Bangun image
|
|
run: |
|
|
docker build -t "$IMAGE:${{ github.sha }}" -t "$IMAGE:latest" .
|
|
|
|
- name: Kirim ke registry
|
|
run: |
|
|
docker push "$IMAGE:${{ github.sha }}"
|
|
docker push "$IMAGE:latest"
|
|
|
|
- name: Deploy ke staging
|
|
run: |
|
|
ssh -o StrictHostKeyChecking=no [email protected] \
|
|
"deploy hello-ci $IMAGE:${{ github.sha }} 8081 80"
|
|
|
|
- name: Pastikan staging hidup
|
|
run: |
|
|
sleep 5
|
|
curl -fsS -o /dev/null -w 'staging HTTP %{http_code}\n' http://192.168.0.118:8081
|
|
|
|
produksi:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: github.event_name == 'workflow_dispatch'
|
|
steps:
|
|
- name: Deploy ke production
|
|
run: |
|
|
ssh -o StrictHostKeyChecking=no [email protected] \
|
|
"deploy hello-ci $IMAGE:${{ github.sha }} 8081 80"
|
|
- name: Pastikan production hidup
|
|
run: |
|
|
sleep 5
|
|
curl -fsS -o /dev/null -w 'production HTTP %{http_code}\n' http://192.168.0.119:8081
|