Add Forgejo Actions CI/CD workflow
Some checks failed
Build and Deploy / build-and-push (push) Failing after 57s
Some checks failed
Build and Deploy / build-and-push (push) Failing after 57s
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 <noreply@paperclip.ing>
This commit is contained in:
parent
7c06647953
commit
2a56f9cd6b
1 changed files with 71 additions and 0 deletions
71
.forgejo/workflows/build-and-deploy.yaml
Normal file
71
.forgejo/workflows/build-and-deploy.yaml
Normal file
|
|
@ -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 <noreply@paperclip.ing>" &&
|
||||
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
|
||||
Loading…
Add table
Reference in a new issue