-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (61 loc) · 2.14 KB
/
deploy-apps.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
name: Deploy apps
on:
workflow_run:
workflows: [Build apps]
types: [completed]
workflow_dispatch:
env:
REGISTRY: ghcr.io
DOCKER_HOST: ssh://target
TELEGRAM_IMAGE_NAME: ${{ github.repository }}-telegram
DISCORD_IMAGE_NAME: ${{ github.repository }}-discord
jobs:
deploy:
name: Deploy
if: ${{
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.event != 'pull_request' && github.event.workflow_run.conclusion == 'success')
}}
runs-on: ubuntu-latest
permissions:
packages: read
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: compose.yaml
sparse-checkout-cone-mode: false
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.6.1
with:
images: |
${{ env.REGISTRY }}/${{ env.TELEGRAM_IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.DISCORD_IMAGE_NAME }}
- name: Install cloudflared
run: |
curl -L -o cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared.deb
- name: Load SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
config: ${{ vars.SSH_CONFIG }}
- name: Deploy Docker image to server
env:
TUNNEL_SERVICE_TOKEN_ID: ${{ secrets.CLOUDFLARE_ACCESS_ID }}
TUNNEL_SERVICE_TOKEN_SECRET: ${{ secrets.CLOUDFLARE_ACCESS_SECRET }}
TELEGRAM_IMAGE_REF: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
DISCORD_IMAGE_REF: ${{ fromJSON(steps.meta.outputs.json).tags[1] }}
WORKER_AUTH: ${{ secrets.CLOUDFLARE_WORKER_AUTH }}
run: |
docker compose pull
docker compose up -d