Aplikasi uji CI/CD versi 1
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
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
|
||||
@@ -0,0 +1,2 @@
|
||||
FROM nginx:alpine
|
||||
COPY index.html /usr/share/nginx/html/index.html
|
||||
@@ -0,0 +1,5 @@
|
||||
<!doctype html>
|
||||
<html lang=id><meta charset=utf-8><title>hello-ci</title>
|
||||
<style>body{font-family:system-ui;display:grid;place-items:center;min-height:100vh;margin:0;background:#0c0a09;color:#fafaf9}
|
||||
h1{font-size:3rem;margin:0}p{color:#a8a29e}</style>
|
||||
<div style=text-align:center><h1>hello-ci</h1><p>Versi 1 — dibangun otomatis oleh Gitea Actions</p></div>
|
||||
Reference in New Issue
Block a user