feat: add GitHub Actions workflows for release management and Docker … #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| release: | |
| types: | |
| - created | |
| jobs: | |
| docker-release: | |
| name: Build and Push Docker Images | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository_owner }}/markitdown-server | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern=v{{version}} | |
| type=semver,pattern=v{{major}}.{{minor}} | |
| type=semver,pattern=v{{major}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=sha,prefix=sha- | |
| - name: Set build time | |
| id: build_time | |
| run: echo "BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S')" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| push: ${{ github.event_name == 'release' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| VERSION=${{ github.ref_name}} | |
| COMMIT_HASH=${{ github.sha }} | |
| BUILD_TIME=${{ steps.build_time.outputs.BUILD_TIME }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| k8s-deploy: | |
| name: Deploy to Kubernetes | |
| needs: docker-release | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up kubectl | |
| uses: azure/setup-kubectl@v4 | |
| with: | |
| version: "latest" | |
| - name: Configure kubectl | |
| run: | | |
| mkdir -p ~/.kube | |
| echo "${{ secrets.K8S_CONFIG_FILE_B64 }}" | base64 -d > ~/.kube/config | |
| chmod 600 ~/.kube/config | |
| - name: Verify kubectl connection | |
| run: kubectl cluster-info | |
| - name: Update deployment image | |
| run: | | |
| # Extract version from release tag | |
| VERSION="${{ github.ref_name }}" | |
| # Update kustomization with new image tag | |
| cd k8s | |
| kubectl kustomize . | kubectl apply -f - | |
| # Update the deployment with the specific release tag | |
| kubectl set image deployment/markitdown-server markitdown-server=ghcr.io/${{ github.repository_owner }}/markitdown-server:${VERSION} -n markitdown-server | |
| # Wait for rollout to complete | |
| kubectl rollout status deployment/markitdown-server -n markitdown-server --timeout=300s | |
| - name: Verify deployment | |
| run: | | |
| kubectl get pods -n markitdown-server -l app=markitdown-server | |
| kubectl get service -n markitdown-server markitdown-server |