-
Notifications
You must be signed in to change notification settings - Fork 43
91 lines (80 loc) · 2.78 KB
/
server-cd.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
87
88
89
90
91
name: Server CD
on:
push:
branches:
- "dev"
workflow_dispatch:
jobs:
server-changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
src: ${{ steps.filter.outputs.src }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
src:
- ".github/workflows/server-cd.yml"
- "violet-server/**"
deploy-by-docker:
needs: server-changes
if: ${{ needs.app-changes.outputs.src == 'true' || github.event_name != 'push' }}
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
ref: master
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:violet-server"
push: true
tags: violetdev/violet:latest
- name: Diploy
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.WEBHOOK_URL }}
method: "POST"
timeout: 60000
- name: CD Success
if: success()
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "Success Deploy!"
color: 0x28e1ff
nodetail: true
description: |
Commit: [${{ github.event.head_commit.message }}](https://github.com/project-violet/violet-server/commit/${{ github.sha }})
CI Log: [${{ github.ref }} / ${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
- name: CD Fail
if: failure()
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "Failed to Deploy"
nodetail: true
color: 0xff9300
content: "<@614104830738169877>"
description: |
Commit: [${{ github.event.head_commit.message }}](https://github.com/project-violet/violet-server/commit/${{ github.sha }})
CI Log: [${{ github.ref }} / ${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})