From 1f3bbc8d40cea4a48914ce803efed58a49ba0090 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Mon, 19 Jan 2026 15:46:42 -0500 Subject: [PATCH] Fix prod/nonprod --- .github/workflows/api-deploy-nonprod.yml | 1 - .github/workflows/api-deploy-prod.yml | 187 +++++++++++------------ 2 files changed, 93 insertions(+), 95 deletions(-) diff --git a/.github/workflows/api-deploy-nonprod.yml b/.github/workflows/api-deploy-nonprod.yml index 7fdb54d..4270f2f 100644 --- a/.github/workflows/api-deploy-nonprod.yml +++ b/.github/workflows/api-deploy-nonprod.yml @@ -91,4 +91,3 @@ jobs: - name: Deploy to Coolify run: | curl -X GET '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' - diff --git a/.github/workflows/api-deploy-prod.yml b/.github/workflows/api-deploy-prod.yml index 63ff524..fc13d6d 100644 --- a/.github/workflows/api-deploy-prod.yml +++ b/.github/workflows/api-deploy-prod.yml @@ -1,94 +1,93 @@ -name: API Deployment Production -on: - workflow_call: - inputs: - environments: - type: string - description: An optional list of environments to deploy to. - default: 'prod' - workflow_type: - type: string - description: An optional string for workflow types. - default: 'prod' - branch: - type: string - description: An optional string to define which branch to checkout. - default: 'main' - current_version: - type: string - description: Current Version of the package.json. - default: '0.0.0' - secrets: - DOCKERHUB_USER: {} - DOCKERHUB_TOKEN: {} - TEST: {} - COOLIFY_WEBHOOK_API: {} - COOLIFY_TOKEN: {} -jobs: - check-inputs: - runs-on: 'ubuntu-latest' - environment: ${{ inputs.environments }} - steps: - - name: Check secrets present - run: | - if [[ -z "${{ secrets.COOLIFY_WEBHOOK_API }}" ]]; then - echo "COOLIFY_WEBHOOK_API secret is empty or missing" - exit 1 - else - echo "COOLIFY_WEBHOOK_API 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 - echo "Current Version: ${{inputs.current_version}}" - 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 api/Dockerfile -t john4064/shiftsync:prod_api ./api --build-arg ENVIRONMENT=prod - - name: Docker Push Backend - run: docker push john4064/shiftsync:prod_api - 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_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' - +name: API Deployment Production +on: + workflow_call: + inputs: + environments: + type: string + description: An optional list of environments to deploy to. + default: 'prod' + workflow_type: + type: string + description: An optional string for workflow types. + default: 'prod' + branch: + type: string + description: An optional string to define which branch to checkout. + default: 'main' + current_version: + type: string + description: Current Version of the package.json. + default: '0.0.0' + secrets: + DOCKERHUB_USER: {} + DOCKERHUB_TOKEN: {} + TEST: {} + COOLIFY_WEBHOOK_API: {} + COOLIFY_TOKEN: {} +jobs: + check-inputs: + runs-on: 'ubuntu-latest' + environment: ${{ inputs.environments }} + steps: + - name: Check secrets present + run: | + if [[ -z "${{ secrets.COOLIFY_WEBHOOK_API }}" ]]; then + echo "COOLIFY_WEBHOOK_API secret is empty or missing" + exit 1 + else + echo "COOLIFY_WEBHOOK_API 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 + echo "Current Version: ${{inputs.current_version}}" + 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 api/Dockerfile -t john4064/shiftsync:prod_api ./api --build-arg ENVIRONMENT=prod + - name: Docker Push Backend + run: docker push john4064/shiftsync:prod_api + 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 -X GET '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'