-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (78 loc) · 2.72 KB
/
deploy-strapi-eks.yml
File metadata and controls
95 lines (78 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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