Skip to content

Commit 55d19a8

Browse files
committed
[Recognizer] Setup Recognizer CD
1 parent 395f5dc commit 55d19a8

File tree

5 files changed

+108
-3
lines changed

5 files changed

+108
-3
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
app-name:
5+
required: true
6+
type: string
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
11+
jobs:
12+
build-publish-image:
13+
name: "Build and publish Docker Image"
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
- name: Login to Container Registry
20+
uses: docker/login-action@v2
21+
with:
22+
registry: ${{ env.REGISTRY }}
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Extract metadata (tags, labels) for Docker
26+
id: meta
27+
uses: docker/metadata-action@v4
28+
with:
29+
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ inputs.app-name }}
30+
tags: type=match,pattern=${{ inputs.app-name }}-v(.*),group=1
31+
- name: Build and push Docker image
32+
uses: docker/build-push-action@v4
33+
with:
34+
context: ./${{ inputs.app-name }}
35+
platforms: linux/amd64
36+
push: true
37+
tags: ${{ steps.meta.outputs.tags }}
38+
cache-from: type=gha
39+
cache-to: type=gha,mode=max
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
app-name:
5+
required: true
6+
type: string
7+
secrets:
8+
ssh-host:
9+
required: true
10+
ssh-username:
11+
required: true
12+
ssh-priv-key:
13+
required: true
14+
secret-key-base:
15+
required: true
16+
phx-host:
17+
required: true
18+
19+
jobs:
20+
deploy-image:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Deploy Image
25+
uses: appleboy/ssh-action@v1.0.3
26+
with:
27+
host: ${{ secrets.ssh-host }}
28+
username: ${{ secrets.ssh-username }}
29+
key: ${{ secrets.ssh-priv-key }}
30+
script: |
31+
export TAG=${{ github.ref_name }}
32+
export TAG=${TAG#*-v}
33+
echo ${TAG}
34+
docker stop ${{ inputs.app-name }}
35+
docker rm ${{ inputs.app-name }}
36+
docker run -d --restart unless-stopped --name ${{ inputs.app-name }} -e SECRET_KEY_BASE=${{ secrets.secret-key-base }} -e PHX_HOST=${{ secrets.phx-host }} -e PORT=${{ secrets.port }} --network host ghcr.io/elixir-webrtc/apps/${{ inputs.app-name }}:${TAG}
37+
docker image prune --all --force
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Recognizer CD
2+
3+
on:
4+
push:
5+
tags:
6+
- "recognizer-v*.*.*"
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
build-publish-recognizer-image:
14+
name: "Build and publish Recognizer Docker image"
15+
uses: ./.github/workflows/__CD__build-publish-image.yml
16+
with:
17+
app-name: recognizer
18+
deploy-recognizer:
19+
name: "Deploy Recognizer Image"
20+
needs: build-publish-recognizer-image
21+
uses: ./.github/workflows/__CD__deploy-image.yml
22+
with:
23+
app-name: recognizer
24+
secrets:
25+
ssh-host: ${{ secrets.RECOGNIZER_SSH_HOST }}
26+
ssh-username: ${{ secrets.RECOGNIZER_SSH_USERNAME }}
27+
ssh-priv-key: ${{ secrets.RECOGNIZER_SSH_PRIV_KEY }}
28+
secret-key-base: ${{ secrets.RECOGNIZER_SECRET_KEY_BASE }}
29+
phx-host: ${{ secrets.RECOGNIZER_PHX_HOST }}

.github/workflows/ci.yml renamed to .github/workflows/__CI__all.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ permissions:
88
jobs:
99
build_check_recognizer:
1010
name: Recognizer CI
11-
uses: ./.github/workflows/build-check-app.yml
11+
uses: ./.github/workflows/__CI__build-check-app.yml
1212
with:
1313
workdir: recognizer
1414
with-ffmpeg: true
1515

1616
build_check_broadcaster:
1717
name: Broadcaster CI
18-
uses: ./.github/workflows/build-check-app.yml
18+
uses: ./.github/workflows/__CI__build-check-app.yml
1919
with:
2020
workdir: broadcaster
2121

2222
build_check_nexus:
2323
name: Nexus CI
24-
uses: ./.github/workflows/build-check-app.yml
24+
uses: ./.github/workflows/__CI__build-check-app.yml
2525
with:
2626
workdir: nexus

0 commit comments

Comments
 (0)