forked from AirenSoft/OvenMediaEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (139 loc) · 4.52 KB
/
sandbox.yaml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: CI/CD pipeline for Sandbox
on:
push:
branches:
- develop
- feature/SRE-362-github-actions
env:
# Manage your service
SERVICE_NAME: ome
# Defaults for docker
ENVIRONMENT_NAME: sandbox
DOCKERFILE: ./Dockerfile
DOCKER_COMPOSE: .deployment/docker-compose.yaml
DOCKER_COMPOSE_DEPLOY: .deployment/compose-deploy.yaml
COMPOSE_ENV_FILE: .deployment/.env
COMPOSE_APP_ENV_FILE: .deployment/.env.compose
jobs:
dockerize:
name: Build and Push Docker image to Registry
runs-on: ubuntu-20.04
environment: sandbox
steps:
-
name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 2
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Setup QEMU
uses: docker/[email protected]
-
name: Setup Docker Buildx
uses: docker/[email protected]
-
name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Setup Lowercase Repository
id: repository
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
-
name: Set version output
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
-
name: Build and Push Container image
uses: docker/build-push-action@v5
with:
file: ${{ env.DOCKERFILE }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
target: release
tags: |
ghcr.io/${{ steps.repository.outputs.lowercase }}:develop
ghcr.io/${{ steps.repository.outputs.lowercase }}:${{ env.sha_short }}
deploy:
name: Deploy Sandbox Service
runs-on: [self-hosted, linux, x64, ome-poc, hybiot, internal]
environment: sandbox
needs:
- dockerize
steps:
-
name: Setup Lowercase Repository
id: repository
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
-
name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 2
-
name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set version output
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
-
name: Create env Docker-Compose
run: |
touch ${{ env.COMPOSE_ENV_FILE }}
echo '' > ${{ env.COMPOSE_ENV_FILE }}
echo IMAGE_NAME=ghcr.io/${{ steps.repository.outputs.lowercase }} >> ${{ env.COMPOSE_ENV_FILE }}
echo IMAGE_TAG=${{ env.sha_short }} >> ${{ env.COMPOSE_ENV_FILE }}
echo SERVICE_NAME=${{ env.SERVICE_NAME }} >> ${{ env.COMPOSE_ENV_FILE }}
touch ${{ env.COMPOSE_APP_ENV_FILE }}
cat .deployment/.env.${{ env.ENVIRONMENT_NAME }} >> ${{ env.COMPOSE_APP_ENV_FILE }}
envsubst < ${{ env.DOCKER_COMPOSE }} > ${{ env.DOCKER_COMPOSE_DEPLOY }}
env:
IMAGE_NAME: ghcr.io/${{ steps.repository.outputs.lowercase }}
IMAGE_TAG: ${{ env.sha_short }}
SERVICE_NAME: ${{ env.SERVICE_NAME }}
-
name: Starting docker compose services
run: |
docker compose -f ${{ env.DOCKER_COMPOSE_DEPLOY }} pull
docker compose -f ${{ env.DOCKER_COMPOSE_DEPLOY }} up -d
docker ps -a
env:
COMPOSE_HTTP_TIMEOUT: 600
SERVICE_NAME: ${{ env.SERVICE_NAME }}
notify:
name: Discord Notification
runs-on: ubuntu-20.04
needs:
- dockerize
- deploy
if: ${{ always() }}
steps:
- name: Notify
uses: nobrayner/discord-webhook@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
discord-webhook: ${{ secrets.ACTIONS_DISCORD_WEBHOOK }}
title: '{{STATUS}} : ${{ github.workflow }}'
description: '[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})'
include-details: 'true'
color-success: '#1a7f37'
color-failure: '#cf222e'
color-cancelled: '#7c848d'