57 lines
1.4 KiB
YAML
57 lines
1.4 KiB
YAML
name: Build & Deploy Fiddy (Dokploy)
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
|
|
env:
|
|
REGISTRY: git.nicosaya.com/nalalangan/fiddy
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run tests
|
|
run: npm test --if-present
|
|
|
|
- name: Docker login
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASS }}" | docker login $REGISTRY -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
|
|
|
- name: Build Web Image
|
|
run: |
|
|
docker build -t $REGISTRY/web:${{ github.sha }} -t $REGISTRY/web:main -f docker/Dockerfile .
|
|
|
|
- name: Push Web Image
|
|
run: |
|
|
docker push $REGISTRY/web:${{ github.sha }}
|
|
docker push $REGISTRY/web:main
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Trigger Dokploy Deploy
|
|
env:
|
|
DOKPLOY_DEPLOY_HOOK: ${{ secrets.DOKPLOY_DEPLOY_HOOK }}
|
|
IMAGE_TAG: ${{ github.sha }}
|
|
run: |
|
|
if [ -z "$DOKPLOY_DEPLOY_HOOK" ]; then
|
|
echo "Missing DOKPLOY_DEPLOY_HOOK secret"
|
|
exit 1
|
|
fi
|
|
curl -fsS -X POST "$DOKPLOY_DEPLOY_HOOK" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"imageTag\":\"$IMAGE_TAG\"}"
|