From 2a56f9cd6b39eef63d0ec031404e2432ce96ad7a Mon Sep 17 00:00:00 2001 From: "CTO (Paperclip Agent)" Date: Sat, 18 Jul 2026 14:23:05 +0000 Subject: [PATCH] Add Forgejo Actions CI/CD workflow Create automated build and deploy workflow that: - Triggers on push to main branch - Builds Docker image with timestamped tag - Pushes to registry.basicstack.de (10.106.73.119:5000) - Updates k8s/20-deployment.yaml with new image tag - Commits manifest update for Argo CD to sync Part of DEV-334 CI/CD workflow implementation. Co-Authored-By: Paperclip --- .forgejo/workflows/build-and-deploy.yaml | 71 ++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .forgejo/workflows/build-and-deploy.yaml diff --git a/.forgejo/workflows/build-and-deploy.yaml b/.forgejo/workflows/build-and-deploy.yaml new file mode 100644 index 0000000..cf752d6 --- /dev/null +++ b/.forgejo/workflows/build-and-deploy.yaml @@ -0,0 +1,71 @@ +name: Build and Deploy + +on: + push: + branches: + - main + +env: + REGISTRY: 10.106.73.119:5000 + IMAGE_NAME: basicstack-web + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker image tags + id: meta + run: | + echo "TAG=$(date +%Y%m%d-%H%M%S)-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT + echo "FULL_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$(date +%Y%m%d-%H%M%S)-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT + echo "LATEST_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT + + - name: Build Docker image + run: | + docker build \ + -t ${{ steps.meta.outputs.FULL_IMAGE }} \ + -t ${{ steps.meta.outputs.LATEST_IMAGE }} \ + -f Dockerfile . + + - name: Log in to container registry + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} \ + -u paperclip --password-stdin + + - name: Push Docker image + run: | + docker push ${{ steps.meta.outputs.FULL_IMAGE }} + docker push ${{ steps.meta.outputs.LATEST_IMAGE }} + + - name: Update deployment manifest + run: | + cd k8s + sed -i "s|image:.*basicstack-web.*|image: ${{ steps.meta.outputs.FULL_IMAGE }}|" 20-deployment.yaml + cat 20-deployment.yaml | grep -A2 "image:" + + - name: Commit and push manifest update + run: | + git config user.name "Forgejo Actions" + git config user.email "actions@forgejo.basicstack.de" + git add k8s/20-deployment.yaml + git diff --cached --exit-code || ( + git commit -m "chore: update deployment image to ${{ steps.meta.outputs.TAG }} + + Automated image update from CI/CD workflow. + + Co-Authored-By: Paperclip " && + git push origin main + ) + + - name: Deployment summary + run: | + echo "## Deployment Complete" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "- **Image**: ${{ steps.meta.outputs.FULL_IMAGE }}" >> $GITHUB_STEP_SUMMARY + echo "- **Registry**: ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY + echo "- **Manifest updated**: k8s/20-deployment.yaml" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Argo CD will automatically sync the deployment to the cluster." >> $GITHUB_STEP_SUMMARY