feat: convert workflows to tag-based deployment with semantic versioning
- Replace branch triggers with tag triggers for all services - Backend: backend-dev-v1.0.0 - Learner: learner-dev-v1.0.0 - Management: management-dev-v1.0.0 - Extract version from tags and use for Docker image tagging - Update compose.yaml to use GITEA_INSTANCE variable - Add comprehensive deployment guide (DEPLOYMENT.md) - Support pre-release tags (beta, rc, alpha) BREAKING CHANGE: Pushing to dev branch no longer triggers deployment. Must create and push version tags to deploy.
This commit is contained in:
parent
025084b2bf
commit
e7a2ac8b5a
5 changed files with 489 additions and 46 deletions
|
|
@ -2,11 +2,9 @@ name: Build and Deploy Backend
|
|||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "Backend/**"
|
||||
- ".forgejo/workflows/deploy-backend.yaml"
|
||||
tags:
|
||||
- "backend-dev-v[0-9]+.[0-9]+.[0-9]+"
|
||||
- "backend-dev-v[0-9]+.[0-9]+.[0-9]+-*"
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
|
|
@ -16,7 +14,6 @@ env:
|
|||
|
||||
# Docker Image
|
||||
BACKEND_IMAGE_NAME: chamomind/elearning-backend
|
||||
IMAGE_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
|
||||
# Notifications
|
||||
DISCORD_WEBHOOK_URL: ${{ vars.DISCORD_WEBHOOK_URL }}
|
||||
|
|
@ -26,14 +23,22 @@ jobs:
|
|||
name: Build Backend Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
short_sha: ${{ steps.vars.outputs.short_sha }}
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Generate short SHA
|
||||
id: vars
|
||||
run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||
# Tag: backend-dev-v1.2.3 → Version: 1.2.3
|
||||
VERSION=$(echo "${{ github.ref_name }}" | sed 's/backend-dev-v//g')
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
# Manual run: use latest-{run_number}
|
||||
echo "version=latest-${{ github.run_number }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
|
|
@ -56,9 +61,8 @@ jobs:
|
|||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=sha,prefix=
|
||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
|
||||
type=raw,value=${{ steps.version.outputs.version }}
|
||||
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
|
||||
|
||||
- name: Build and Push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
|
|
@ -86,7 +90,7 @@ jobs:
|
|||
script: |
|
||||
cd ~/repo
|
||||
chmod +x ./replace-env.sh ./deploy.sh
|
||||
./replace-env.sh BACKEND_TAG "${{ needs.build.outputs.short_sha }}"
|
||||
./replace-env.sh BACKEND_TAG "${{ needs.build.outputs.version }}"
|
||||
./deploy.sh backend
|
||||
|
||||
notify:
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ name: Build and Deploy Frontend Learner
|
|||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "Frontend-Learner/**"
|
||||
- ".forgejo/workflows/deploy-frontend-learner.yaml"
|
||||
tags:
|
||||
- "learner-dev-v[0-9]+.[0-9]+.[0-9]+"
|
||||
- "learner-dev-v[0-9]+.[0-9]+.[0-9]+-*"
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
|
|
@ -25,14 +23,22 @@ jobs:
|
|||
name: Build Frontend Learner Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
short_sha: ${{ steps.short_sha.outputs.sha }}
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Generate short SHA
|
||||
id: short_sha
|
||||
run: echo "sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||
# Tag: learner-dev-v1.2.3 → Version: 1.2.3
|
||||
VERSION=$(echo "${{ github.ref_name }}" | sed 's/learner-dev-v//g')
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
# Manual run: use latest-{run_number}
|
||||
echo "version=latest-${{ github.run_number }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
|
|
@ -55,9 +61,8 @@ jobs:
|
|||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=sha,prefix=
|
||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
|
||||
type=raw,value=${{ steps.version.outputs.version }}
|
||||
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
|
||||
|
||||
- name: Build and Push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
|
|
@ -85,7 +90,7 @@ jobs:
|
|||
script: |
|
||||
cd ~/repo
|
||||
chmod +x ./replace-env.sh ./deploy.sh
|
||||
./replace-env.sh FRONTEND_TAG "${{ needs.build.outputs.short_sha }}"
|
||||
./replace-env.sh FRONTEND_TAG "${{ needs.build.outputs.version }}"
|
||||
./deploy.sh learner
|
||||
|
||||
notify:
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ name: Build and Deploy Frontend Management to Dev Server
|
|||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "frontend_management/**"
|
||||
- ".forgejo/workflows/deploy-frontend-management.yaml"
|
||||
tags:
|
||||
- "management-dev-v[0-9]+.[0-9]+.[0-9]+"
|
||||
- "management-dev-v[0-9]+.[0-9]+.[0-9]+-*"
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
|
|
@ -25,14 +23,22 @@ jobs:
|
|||
name: Build Frontend Management Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
short_sha: ${{ steps.short_sha.outputs.sha }}
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Generate short SHA
|
||||
id: short_sha
|
||||
run: echo "sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||
# Tag: management-dev-v1.2.3 → Version: 1.2.3
|
||||
VERSION=$(echo "${{ github.ref_name }}" | sed 's/management-dev-v//g')
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
# Manual run: use latest-{run_number}
|
||||
echo "version=latest-${{ github.run_number }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
|
|
@ -55,9 +61,8 @@ jobs:
|
|||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=sha,prefix=
|
||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
|
||||
type=raw,value=${{ steps.version.outputs.version }}
|
||||
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
|
||||
|
||||
- name: Build and Push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
|
|
@ -85,7 +90,7 @@ jobs:
|
|||
script: |
|
||||
cd ~/repo
|
||||
chmod +x ./replace-env.sh ./deploy.sh
|
||||
./replace-env.sh MANAGEMENT_TAG "${{ needs.build.outputs.short_sha }}"
|
||||
./replace-env.sh MANAGEMENT_TAG "${{ needs.build.outputs.version }}"
|
||||
./deploy.sh management
|
||||
|
||||
notify:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue