fix: update CI/CD workflows to match DocFast pattern
- deploy.yml: proper Docker buildx setup, arm64 build, kubectl deploy to staging - promote.yml: production deploy on v* tags with proper image tagging
This commit is contained in:
parent
e49c4073f8
commit
2ad648aeaa
2 changed files with 53 additions and 50 deletions
|
|
@ -1,40 +1,44 @@
|
||||||
name: Deploy to Staging
|
name: Build & Deploy to Staging
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-stage:
|
||||||
|
name: Build & Deploy to Staging
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to Forgejo Registry
|
||||||
- name: Login to Container Registry
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: git.cloonar.com
|
registry: git.cloonar.com
|
||||||
username: ${{ github.actor }}
|
username: openclawd
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
- name: Build and Push
|
||||||
- name: Build and push Docker image
|
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/arm64
|
|
||||||
push: true
|
push: true
|
||||||
|
no-cache: true
|
||||||
tags: |
|
tags: |
|
||||||
git.cloonar.com/openclawd/snapapi:staging
|
git.cloonar.com/openclawd/snapapi:latest
|
||||||
git.cloonar.com/openclawd/snapapi:${{ github.sha }}
|
git.cloonar.com/openclawd/snapapi:${{ github.sha }}
|
||||||
cache-from: type=gha
|
platforms: linux/arm64
|
||||||
cache-to: type=gha,mode=max
|
- name: Deploy to Staging
|
||||||
|
|
||||||
- name: Deploy to staging
|
|
||||||
run: |
|
run: |
|
||||||
echo "Triggering staging deployment..."
|
curl -sLO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
# The actual deployment is handled by ArgoCD or similar GitOps tool
|
chmod +x kubectl
|
||||||
# This would typically update a helm chart or kubernetes manifest repo
|
echo "${{ secrets.KUBECONFIG }}" | base64 -d > /tmp/kubeconfig.yaml
|
||||||
|
./kubectl set image deployment/snapapi \
|
||||||
|
snapapi=git.cloonar.com/openclawd/snapapi:${{ github.sha }} \
|
||||||
|
-n snapapi-staging --kubeconfig=/tmp/kubeconfig.yaml
|
||||||
|
./kubectl rollout status deployment/snapapi \
|
||||||
|
-n snapapi-staging --kubeconfig=/tmp/kubeconfig.yaml --timeout=180s
|
||||||
|
echo "✅ Staging deploy complete!"
|
||||||
|
|
|
||||||
|
|
@ -6,40 +6,39 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
promote:
|
promote:
|
||||||
|
name: Promote to Production
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up QEMU
|
||||||
- name: Login to Container Registry
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to Forgejo Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: git.cloonar.com
|
registry: git.cloonar.com
|
||||||
username: ${{ github.actor }}
|
username: openclawd
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
- name: Build and Push Production
|
||||||
- name: Get latest staging image
|
uses: docker/build-push-action@v5
|
||||||
id: get_image
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
no-cache: true
|
||||||
|
tags: |
|
||||||
|
git.cloonar.com/openclawd/snapapi:prod
|
||||||
|
git.cloonar.com/openclawd/snapapi:${{ github.ref_name }}
|
||||||
|
platforms: linux/arm64
|
||||||
|
- name: Deploy to Production
|
||||||
run: |
|
run: |
|
||||||
# Get the latest staging image digest
|
curl -sLO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
STAGING_DIGEST=$(docker manifest inspect git.cloonar.com/openclawd/snapapi:staging --verbose | jq -r '.Descriptor.digest')
|
chmod +x kubectl
|
||||||
echo "staging_digest=$STAGING_DIGEST" >> $GITHUB_OUTPUT
|
echo "${{ secrets.KUBECONFIG }}" | base64 -d > /tmp/kubeconfig.yaml
|
||||||
|
./kubectl set image deployment/snapapi \
|
||||||
# Extract version from tag
|
snapapi=git.cloonar.com/openclawd/snapapi:${{ github.ref_name }} \
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
-n snapapi --kubeconfig=/tmp/kubeconfig.yaml
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
./kubectl rollout status deployment/snapapi \
|
||||||
|
-n snapapi --kubeconfig=/tmp/kubeconfig.yaml --timeout=180s
|
||||||
- name: Re-tag for production
|
echo "✅ Production deploy complete!"
|
||||||
run: |
|
|
||||||
# Pull staging image and re-tag for production
|
|
||||||
docker buildx imagetools create \
|
|
||||||
--tag git.cloonar.com/openclawd/snapapi:latest \
|
|
||||||
--tag git.cloonar.com/openclawd/snapapi:${{ steps.get_image.outputs.version }} \
|
|
||||||
--tag git.cloonar.com/openclawd/snapapi:prod \
|
|
||||||
git.cloonar.com/openclawd/snapapi:staging
|
|
||||||
|
|
||||||
- name: Deploy to production
|
|
||||||
run: |
|
|
||||||
echo "Triggering production deployment for version ${{ steps.get_image.outputs.version }}..."
|
|
||||||
# The actual deployment is handled by ArgoCD or similar GitOps tool
|
|
||||||
# This would typically update a helm chart or kubernetes manifest repo
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue