-
-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (86 loc) · 3.65 KB
/
deploy.yml
File metadata and controls
97 lines (86 loc) · 3.65 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
96
97
name: BuildEngine v2 Deploy to AWS
on:
workflow_call:
inputs:
BUILD_NUMBER:
type: 'string'
required: true
ECS_CLUSTER:
type: 'string'
required: true
DOCKER_TAG:
type: 'string'
required: true
BUILD_ENGINE_TAG:
type: 'string'
required: true
OTEL_TAG:
type: 'string'
required: true
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
AWS_DEFAULT_REGION:
required: true
AWS_ECR_ACCOUNT:
required: true
jobs:
deploy-to-ecr:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
echo "Installing ecs-deploy script..."
mkdir -p $HOME/.local/bin
curl -o $HOME/.local/bin/ecs-deploy https://raw.githubusercontent.com/silinternational/ecs-deploy/master/ecs-deploy
chmod +x $HOME/.local/bin/ecs-deploy
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull from GHCR
run: |
docker pull ${{ inputs.BUILD_ENGINE_TAG }}
docker pull ${{ inputs.OTEL_TAG }}
docker image list
- name: Configure AWS credentials
id: aws
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Login to AWS ECR
id: ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registries: ${{ secrets.AWS_ECR_ACCOUNT }}
- name: Build deployment target variables
id: vars
run: |
echo "Setting up deployment variables..."
echo "IMAGE_URL=${{ steps.ecr.outputs.registry }}/appbuilder-buildengine-api" >> $GITHUB_OUTPUT
echo "OTEL_URL=${{ steps.ecr.outputs.registry }}/appbuilder-buildengine-otel" >> $GITHUB_OUTPUT
- name: Push to AWS ECR
run: |
docker tag ${{ inputs.BUILD_ENGINE_TAG}} "${{ steps.vars.outputs.IMAGE_URL }}:${{ inputs.DOCKER_TAG }}"
docker tag ${{ inputs.BUILD_ENGINE_TAG}} "${{ steps.vars.outputs.IMAGE_URL }}:${{ inputs.BUILD_NUMBER }}"
docker tag ${{ inputs.OTEL_TAG}} "${{ steps.vars.outputs.OTEL_URL }}:${{ inputs.DOCKER_TAG }}"
docker tag ${{ inputs.OTEL_TAG}} "${{ steps.vars.outputs.OTEL_URL }}:${{ inputs.BUILD_NUMBER }}"
echo "Docker images tagged as ${{ inputs.DOCKER_TAG }} and ${{ inputs.BUILD_NUMBER }}"
docker push "${{ steps.vars.outputs.IMAGE_URL }}:${{ inputs.DOCKER_TAG }}"
docker push "${{ steps.vars.outputs.IMAGE_URL }}:${{ inputs.BUILD_NUMBER }}"
echo "Docker images pushed successfully to ${{ steps.vars.outputs.IMAGE_URL }}"
docker push "${{ steps.vars.outputs.OTEL_URL }}:${{ inputs.DOCKER_TAG }}"
docker push "${{ steps.vars.outputs.OTEL_URL }}:${{ inputs.BUILD_NUMBER }}"
echo "Docker images pushed successfully to ${{ steps.vars.outputs.OTEL_URL }}"
- name: Deploy to ECS
if: ${{ inputs.ECS_CLUSTER != 'none' }}
run: |
echo "Deploying ${{ inputs.BUILD_NUMBER }} to ${{ inputs.ECS_CLUSTER }}"
# Deploy to ECS cluster with service name 'build-engine', setting all images to the latest tag
ecs-deploy -c ${{ inputs.ECS_CLUSTER }} -n buildengine -i ignore -to ${{ inputs.BUILD_NUMBER }} --max-definitions 20 --timeout 600