ShiftSync/.github/workflows/web-deploy-nonprod.yml
2025-06-11 17:38:03 -04:00

89 lines
2.8 KiB
YAML

name: Web Deployment Non-Production
on:
workflow_call:
inputs:
environments:
type: string
description: An optional list of environments to deploy to.
default: 'dev'
workflow_type:
type: string
description: An optional string for workflow types.
default: 'dev'
branch:
type: string
description: An optional string to define which branch to checkout.
default: 'main'
secrets:
DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {}
TEST: {}
COOLIFY_WEBHOOK: {}
COOLIFY_TOKEN: {}
jobs:
check-inputs:
runs-on: 'ubuntu-latest'
environment: ${{ inputs.environments }}
steps:
- name: Check secrets present
run: |
if [[ -z "${{ secrets.COOLIFY_WEBHOOK }}" ]]; then
echo "COOLIFY_WEBHOOK secret is empty or missing"
exit 1
else
echo "COOLIFY_WEBHOOK secret is set"
fi
if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
echo "COOLIFY_TOKEN secret is empty or missing"
exit 1
else
echo "COOLIFY_TOKEN secret is set"
fi
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
echo "DOCKERHUB_USER secret is empty or missing"
exit 1
else
echo "DOCKERHUB_USER secret is set"
fi
if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then
echo "DOCKERHUB_TOKEN secret is empty or missing"
exit 1
else
echo "DOCKERHUB_TOKEN secret is set"
fi
build:
needs: check-inputs
if: needs.check-inputs.result == 'success' && inputs.workflow_type != 'release'
environment: ${{ inputs.environments }}
runs-on: 'ubuntu-latest'
permissions:
contents: read
packages: write
steps:
- name: Branch Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Login to Docker
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker Build Backend
run: docker build -f web/Dockerfile -t john4064/shiftsync:latest_web ./web --build-arg ENVIRONMENT=dev
- name: Docker Push Backend
run: docker push john4064/shiftsync:latest_web
deploy:
needs: build
if: needs.build.result == 'success' && inputs.workflow_type != 'release'
environment: ${{ inputs.environments }}
runs-on: 'ubuntu-latest'
permissions:
contents: read
packages: write
steps:
- name: Deploy to Coolify
run: |
curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'