-
Notifications
You must be signed in to change notification settings - Fork 15
100 lines (95 loc) · 4.16 KB
/
sandbox.yml
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
98
99
100
name: Deploy Alloy Samples
on:
push:
branches:
- main
workflow_dispatch:
inputs:
sample:
description: 'Specific sample to deploy (leave empty to deploy all)'
required: false
type: choice
options:
- ajo-content-cards
- ajo-in-app-messages
- ajo-personalization-client-side
- ajo-personalization-hybrid
- ajo-personalization-server-side
- ajo-proposition-interaction-tracking
- target-personalization-client-side
- target-personalization-hybrid
- target-personalization-hybrid-spa
- target-personalization-server-side
- target-top-and-bottom
- media-collection
jobs:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
if [ "${{ github.event.inputs.sample }}" != "" ]; then
echo "matrix={\"include\":[{\"sample\":\"${{ github.event.inputs.sample }}\"}]}" >> $GITHUB_OUTPUT
else
echo "matrix={\"include\":[{\"sample\":\"ajo-content-cards\"},{\"sample\":\"ajo-in-app-messages\"},{\"sample\":\"ajo-personalization-client-side\"},{\"sample\":\"ajo-personalization-hybrid\"},{\"sample\":\"ajo-personalization-server-side\"},{\"sample\":\"ajo-proposition-interaction-tracking\"},{\"sample\":\"target-personalization-client-side\"},{\"sample\":\"target-personalization-hybrid\"},{\"sample\":\"target-personalization-hybrid-spa\"},{\"sample\":\"target-personalization-server-side\"},{\"sample\":\"target-top-and-bottom\"},{\"sample\":\"media-collection\"}]}" >> $GITHUB_OUTPUT
fi
deploy:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Docker Login to ACR
uses: azure/docker-login@v1
with:
login-server: alloysamples.azurecr.io
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Set environment variables
run: |
echo "BASE_PATH=/$(echo ${{ matrix.sample }} | cut -d'-' -f2-)" >> $GITHUB_ENV
if [[ "${{ matrix.sample }}" == ajo-* ]]; then
echo "APP_DOMAIN=ajo.alloyio.com" >> $GITHUB_ENV
echo "COMPOSE_FILE=docker/ajo.yml" >> $GITHUB_ENV
elif [[ "${{ matrix.sample }}" == target-* ]]; then
echo "APP_DOMAIN=target.alloyio.com" >> $GITHUB_ENV
echo "COMPOSE_FILE=docker/target.yml" >> $GITHUB_ENV
elif [[ "${{ matrix.sample }}" == media-* ]]; then
echo "APP_DOMAIN=media.alloyio.com" >> $GITHUB_ENV
echo "COMPOSE_FILE=docker/media.yml" >> $GITHUB_ENV
fi
- name: Install Docker Compose V2
run: |
mkdir -p ~/.docker/cli-plugins/
curl -SL https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
- name: Build and push Docker image
env:
IMAGE_NAME: ${{ matrix.sample }}
run: |
if [[ "${{ matrix.sample }}" == ajo-* ]]; then
SERVICE_NAME=$(echo ${{ matrix.sample }} | sed 's/^ajo-//')
elif [[ "${{ matrix.sample }}" == target-* ]]; then
SERVICE_NAME=$(echo ${{ matrix.sample }} | sed 's/^target-//')
elif [[ "${{ matrix.sample }}" == media-* ]]; then
SERVICE_NAME=$(echo ${{ matrix.sample }} | sed 's/^media-//')
else
SERVICE_NAME=${{ matrix.sample }}
fi
docker compose -f ${{ env.COMPOSE_FILE }} build $SERVICE_NAME
docker compose -f ${{ env.COMPOSE_FILE }} push $SERVICE_NAME
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: ${{ matrix.sample }}
publish-profile: ${{ secrets[format('{0}_PUBLISH_PROFILE', matrix.sample)] }}
images: ${{ secrets.AZURE_CONTAINER_REGISTRY }}/${{ matrix.sample }}:latest