-
-
Notifications
You must be signed in to change notification settings - Fork 57
86 lines (76 loc) · 2.47 KB
/
ClemBot.Bot-Deployment.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
name: ClemBot.Bot-deployment
on:
push:
branches: [ master ]
paths:
- "ClemBot.Bot/**"
workflow_dispatch:
inputs:
name:
description: 'Manual ClemBot.Bot workflow trigger'
required: true
default: 'Manual Deployment'
permissions:
packages: write
env:
REGISTRY: ghcr.io
jobs:
build-push-clembot-bot:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
version: latest
install: true
- name: Extract Docker metadata for main build
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/ClemBotProject/ClemBot.Bot
flavor: |
latest=${{ github.event_name == 'push' }}
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: ./ClemBot.Bot
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha, scope=${{github.repository}}
cache-from: type=gha, scope=${{github.repository}}
deploy-clembot-bot:
runs-on: [self-hosted]
needs: ['build-push-clembot-bot']
steps:
- uses: actions/checkout@v2
- name: Copy Secrets
run: |
cp ~/ClemBot.Api_env.env ./ClemBot.Api/ClemBot.Api_env.env
cp ~/ClemBot.Bot_env.env ./ClemBot.Bot/ClemBot.Bot_env.env
cp ~/ClemBot.Site_env.env ./ClemBot.Site/ClemBot.Site_env.env
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy updated images
run: |
docker-compose pull clembot.bot
docker-compose up -d clembot.bot
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.WEBHOOK_URL }}
uses: "Ilshidur/[email protected]"
with:
args: 'The project {{ EVENT_PAYLOAD.repository.full_name }}/ClemBot.Bot has been deployed.'