Merge pull request #154 from openobserve/dev #81
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: Build and Push Strapi Dev Image to ECR | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| build-and-push: | |
| name: Build Docker Image and Push to Amazon ECR | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Check and Install AWS CLI | |
| run: | | |
| if ! command -v aws &> /dev/null | |
| then | |
| echo "AWS CLI not found. Installing..." | |
| curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
| unzip awscliv2.zip | |
| sudo ./aws/install | |
| else | |
| echo "AWS CLI is already installed." | |
| aws --version | |
| fi | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::325553860333:role/GitHubActionsRole | |
| role-session-name: GitHubActions-BuildPush | |
| aws-region: us-east-2 | |
| - name: Log in to Amazon ECR | |
| run: | | |
| aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 325553860333.dkr.ecr.us-east-2.amazonaws.com | |
| - name: Set version variable | |
| id: vars | |
| run: echo "VERSION=$(date +'%Y%m%d')-${GITHUB_SHA::7}" >> $GITHUB_ENV | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and Push Multi-arch Docker Image | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64,linux/arm64 \ | |
| -t 325553860333.dkr.ecr.us-east-2.amazonaws.com/openobserve/strapi:${VERSION} \ | |
| -t 325553860333.dkr.ecr.us-east-2.amazonaws.com/openobserve/strapi:latest \ | |
| --push \ | |
| . | |
| deploy: | |
| name: Deploy to EKS | |
| runs-on: ubuntu-latest | |
| needs: build-and-push | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::325553860333:role/GitHubActionsRole | |
| role-session-name: GitHubActions-Deploy | |
| aws-region: us-east-2 | |
| - name: Update kube config | |
| run: aws eks update-kubeconfig --name cloud1 --region us-east-2 | |
| - name: Deploy to EKS | |
| run: | | |
| kubectl apply -f k8s/strapi-deployment.yaml | |
| - name: Wait for strapi deployment to be created | |
| run: | | |
| for i in {1..10}; do | |
| kubectl get deployment strapi -n strapi && break | |
| echo "Waiting for deployment to register..." | |
| sleep 5 | |
| done | |
| - name: Restart strapi after apply | |
| run: | | |
| kubectl rollout restart deployment/strapi -n strapi || true | |
| kubectl rollout status deployment/strapi -n strapi --timeout=120s |