Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,39 @@ env:
CODEDEPLOY_DEPLOYMENT_GROUP: weplate-deploy-group

jobs:
Merge-Master-Branch-In-Develop-Branch:
check-main-updated:
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]'
outputs:
should_deploy: ${{ steps.compare.outputs.should_deploy }}
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main

- name: Compare main with origin/main
id: compare
run: |
git remote set-url origin https://github.com/${{ github.repository }}.git
git fetch origin main
LOCAL_SHA=$(git rev-parse HEAD)
REMOTE_SHA=$(git rev-parse origin/main)

echo "📟 Local HEAD: $LOCAL_SHA"
echo "📟 Remote HEAD: $REMOTE_SHA"

if [ "$LOCAL_SHA" = "$REMOTE_SHA" ]; then
echo "✅ No changes. Skipping deploy."
echo "should_deploy=false" >> $GITHUB_OUTPUT
else
echo "🚀 Main branch changed. Proceeding with deploy."
echo "should_deploy=true" >> $GITHUB_OUTPUT

deploy-if-updated:
runs-on: ubuntu-latest
needs: check-main-updated
if: needs.check-main-updated.outputs.should_deploy == 'true'
steps:
- name: Checkout main
uses: actions/checkout@v4
Expand All @@ -38,10 +68,6 @@ jobs:
git merge origin/main --no-ff --no-edit --allow-unrelated-histories
git push origin develop

- name: Checkout main
run: |
git checkout main

- name: Get latest tag
id: get_tag
run: |
Expand Down Expand Up @@ -111,10 +137,13 @@ jobs:

for NAME in "${!services[@]}"; do
echo "🔨 Pushing weplate/$NAME:$VERSION"
echo "🔨 weplate/$NAME:$VERSION tagging clear"
docker push $ECR_REGISTRY/weplate/$NAME:$VERSION
echo "🔨 Push Complete weplate/$NAME:$VERSION in $ECR_REGISTRY"
done

determine-asg-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Determine ASG and Apply Desired Scaling
run: |
BLUE_NAME="blue"
Expand Down Expand Up @@ -288,7 +317,6 @@ jobs:
--auto-scaling-group-name "$DELETE_ASG" \
--min-size 0 --desired-capacity 0 --max-size 0

# Step 2: Terminate instances (if any)
INSTANCE_IDS=$(aws autoscaling describe-auto-scaling-groups \
--auto-scaling-group-names "$DELETE_ASG" \
--query "AutoScalingGroups[0].Instances[*].InstanceId" \
Expand Down
Loading