fix(ci): simplify backend github deployment workflow
This commit is contained in:
parent
be6c238691
commit
22ee7f8544
1 changed files with 22 additions and 79 deletions
101
.github/workflows/build-and-deploy-ghcr.yml
vendored
101
.github/workflows/build-and-deploy-ghcr.yml
vendored
|
|
@ -16,90 +16,33 @@ env:
|
||||||
GITOPS_REPO: Traceworks2023/nxtgauge-gitops
|
GITOPS_REPO: Traceworks2023/nxtgauge-gitops
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
detect-changes:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
services: ${{ steps.detect.outputs.services }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 2
|
|
||||||
|
|
||||||
- name: Detect changed services
|
|
||||||
id: detect
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
ALL_SERVICES='gateway users companies jobs leads job-seekers customers payments employees photographers makeup-artists tutors developers video-editors graphic-designers social-media-managers fitness-trainers catering-services ugc-content-creators cron'
|
|
||||||
|
|
||||||
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
|
|
||||||
CHANGED_FILES="$(git diff --name-only HEAD^ HEAD)"
|
|
||||||
else
|
|
||||||
CHANGED_FILES="$(git ls-files)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
LAST_COMMIT_MSG="$(git log -1 --pretty=%B | tr '\n' ' ')"
|
|
||||||
FORCE_FULL_BUILD=false
|
|
||||||
if echo "$LAST_COMMIT_MSG" | grep -Eiq 'trigger build|force build|rebuild all'; then
|
|
||||||
FORCE_FULL_BUILD=true
|
|
||||||
elif echo "$CHANGED_FILES" | grep -Eq '^(\.github/workflows/|\.forgejo/workflows/|Dockerfile|Cargo\.toml|Cargo\.lock|crates/|scripts/)'; then
|
|
||||||
FORCE_FULL_BUILD=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$FORCE_FULL_BUILD" = true ]; then
|
|
||||||
SERVICES_JSON="$(printf '%s\n' $ALL_SERVICES | python3 -c 'import json,sys; print(json.dumps([line.strip() for line in sys.stdin if line.strip()]))')"
|
|
||||||
echo "services=$SERVICES_JSON" >> "$GITHUB_OUTPUT"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
SERVICES_JSON="$(printf '%s\n' "$CHANGED_FILES" | python3 -c '
|
|
||||||
import json
|
|
||||||
import sys
|
|
||||||
mapping = {
|
|
||||||
"apps/gateway/": "gateway",
|
|
||||||
"apps/users/": "users",
|
|
||||||
"apps/companies/": "companies",
|
|
||||||
"apps/jobs/": "jobs",
|
|
||||||
"apps/leads/": "leads",
|
|
||||||
"apps/job_seekers/": "job-seekers",
|
|
||||||
"apps/customers/": "customers",
|
|
||||||
"apps/payments/": "payments",
|
|
||||||
"apps/employees/": "employees",
|
|
||||||
"apps/photographers/": "photographers",
|
|
||||||
"apps/makeup_artists/": "makeup-artists",
|
|
||||||
"apps/tutors/": "tutors",
|
|
||||||
"apps/developers/": "developers",
|
|
||||||
"apps/video_editors/": "video-editors",
|
|
||||||
"apps/graphic_designers/": "graphic-designers",
|
|
||||||
"apps/social_media_managers/": "social-media-managers",
|
|
||||||
"apps/fitness_trainers/": "fitness-trainers",
|
|
||||||
"apps/catering_services/": "catering-services",
|
|
||||||
"apps/ugc_content_creators/": "ugc-content-creators",
|
|
||||||
"apps/cron/": "cron",
|
|
||||||
}
|
|
||||||
services = []
|
|
||||||
seen = set()
|
|
||||||
for raw in sys.stdin:
|
|
||||||
line = raw.strip()
|
|
||||||
for prefix, service in mapping.items():
|
|
||||||
if line.startswith(prefix) and service not in seen:
|
|
||||||
seen.add(service)
|
|
||||||
services.append(service)
|
|
||||||
break
|
|
||||||
print(json.dumps(services))
|
|
||||||
')"
|
|
||||||
echo "services=$SERVICES_JSON" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
build-deploy:
|
build-deploy:
|
||||||
needs: detect-changes
|
|
||||||
if: needs.detect-changes.outputs.services != '[]'
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 1
|
max-parallel: 4
|
||||||
matrix:
|
matrix:
|
||||||
service: ${{ fromJSON(needs.detect-changes.outputs.services) }}
|
service:
|
||||||
|
- gateway
|
||||||
|
- users
|
||||||
|
- companies
|
||||||
|
- jobs
|
||||||
|
- leads
|
||||||
|
- job-seekers
|
||||||
|
- customers
|
||||||
|
- payments
|
||||||
|
- employees
|
||||||
|
- photographers
|
||||||
|
- makeup-artists
|
||||||
|
- tutors
|
||||||
|
- developers
|
||||||
|
- video-editors
|
||||||
|
- graphic-designers
|
||||||
|
- social-media-managers
|
||||||
|
- fitness-trainers
|
||||||
|
- catering-services
|
||||||
|
- ugc-content-creators
|
||||||
|
- cron
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue