Skip to content

Commit 2cd124e

Browse files
committed
build: add custom quali.chat github workflows
1 parent a79c4e4 commit 2cd124e

4 files changed

Lines changed: 147 additions & 0 deletions

File tree

.github/workflows/dockerhub.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Dockerhub
2+
on:
3+
workflow_dispatch: {}
4+
push:
5+
tags: [v*]
6+
branches:
7+
- 'develop'
8+
- 'main'
9+
concurrency: ${{ github.workflow }}-${{ github.ref_name }}
10+
11+
jobs:
12+
buildx:
13+
name: Docker Buildx
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 50 # needed for docker-package to be able to calculate the version
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3 # v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3 # v3
25+
with:
26+
install: true
27+
28+
- name: Login to Docker Hub
29+
uses: docker/login-action@v3 # v3
30+
with:
31+
username: ${{ secrets.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
34+
- name: Docker meta
35+
id: meta
36+
uses: docker/metadata-action@v5 # v5
37+
with:
38+
images: |
39+
qualichat/qualichat-web
40+
tags: |
41+
type=ref,enable=true,event=branch
42+
type=ref,enable=true,event=tag
43+
type=raw,enable=true,value={{branch}},event=workflow_dispatch
44+
flavor: |
45+
latest=${{ contains(github.ref_name, '-rc.') && 'false' || 'auto' }}
46+
47+
- name: Build and push
48+
uses: docker/build-push-action@v5 # v5
49+
with:
50+
context: .
51+
push: true
52+
platforms: linux/amd64,linux/arm64
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
secrets: |
56+
"GITHUB_TOKEN=${{ secrets.NPM_GITHUB_TOKEN }}"
57+
deploy:
58+
name: Deploy via ssh (staging)
59+
uses: ./.github/workflows/stag_deploy.yaml
60+
secrets: inherit
61+
needs: buildx

.github/workflows/prod_deploy.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Production deploy
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
VERSION:
6+
description: "Version to deploy to prod"
7+
default: "latest"
8+
required: false
9+
type: string
10+
workflow_call:
11+
jobs:
12+
call_deploy:
13+
name: Call Deploy prod via ssh
14+
uses: ./.github/workflows/ssh_deploy.yaml
15+
with:
16+
VERSION: ${{ inputs.VERSION }}
17+
secrets:
18+
DEPLOY_HOST: "${{ secrets.PROD_DEPLOY_HOST }}"
19+
DEPLOY_USERNAME: "${{ secrets.PROD_DEPLOY_USERNAME }}"
20+
DEPLOY_KEY: "${{ secrets.PROD_DEPLOY_KEY }}"

.github/workflows/ssh_deploy.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow is only for inclusion in other workflows.
2+
name: Deploy via ssh
3+
on:
4+
workflow_call:
5+
inputs:
6+
VERSION:
7+
description: "Version to deploy"
8+
required: false
9+
default: "develop"
10+
type: string
11+
secrets:
12+
DEPLOY_HOST:
13+
description: "Host to deploy to"
14+
required: true
15+
DEPLOY_USERNAME:
16+
description: "Username to use for ssh"
17+
required: true
18+
DEPLOY_KEY:
19+
description: "SSH key to use for ssh"
20+
required: true
21+
jobs:
22+
deploy:
23+
name: Deploy via ssh
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Run deploy script
27+
uses: appleboy/ssh-action@v1.0.0
28+
env:
29+
VERSION: "${{ inputs.VERSION }}"
30+
SHA: "${{ github.sha }}"
31+
with:
32+
host: "${{ secrets.DEPLOY_HOST }}"
33+
username: "${{ secrets.DEPLOY_USERNAME }}"
34+
key: "${{ secrets.DEPLOY_KEY }}"
35+
envs: >
36+
SHA
37+
script: |
38+
echo $SHA > ~/element-REVISION || true
39+
docker pull "qualichat/qualichat-web:${{ inputs.VERSION }}" || true
40+
systemctl restart matrix-client-element

.github/workflows/stag_deploy.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Staging deploy
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
VERSION:
6+
description: "Version to deploy to staging"
7+
default: "develop"
8+
required: false
9+
type: string
10+
workflow_call:
11+
inputs:
12+
VERSION:
13+
description: "Version to deploy to staging"
14+
default: "develop"
15+
required: false
16+
type: string
17+
jobs:
18+
call_deploy:
19+
name: Call Deploy stag via ssh
20+
uses: ./.github/workflows/ssh_deploy.yaml
21+
with:
22+
VERSION: ${{ inputs.VERSION }}
23+
secrets:
24+
DEPLOY_HOST: "${{ secrets.STAG_DEPLOY_HOST }}"
25+
DEPLOY_USERNAME: "${{ secrets.STAG_DEPLOY_USERNAME }}"
26+
DEPLOY_KEY: "${{ secrets.STAG_DEPLOY_KEY }}"

0 commit comments

Comments
 (0)