Some checks failed
Build and Deploy / build-and-push (push) Failing after 3s
Install docker-ce-cli in the workflow container before attempting to build Docker images. The node:24-bookworm base image doesn't include Docker CLI, causing the build step to fail with 'command not found'. This enables the workflow to use Docker commands via the mounted Docker socket from the runner. Co-Authored-By: Paperclip <noreply@paperclip.ing>
82 lines
3 KiB
YAML
82 lines
3 KiB
YAML
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: Install Docker CLI
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y ca-certificates curl
|
|
install -m 0755 -d /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
|
chmod a+r /etc/apt/keyrings/docker.asc
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
apt-get update
|
|
apt-get install -y docker-ce-cli
|
|
|
|
- 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
|