-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (128 loc) · 4.15 KB
/
admin_bot-ci.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Admin Bot CI
on:
push:
branches:
- "main"
tags:
- "*"
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
formatblack:
name: Black Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check files using the black formatter
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."
- name: Annotate diff changes using reviewdog
if: steps.action_black.outputs.is_formatted == 'true'
uses: reviewdog/action-suggester@v1
with:
tool_name: blackfmt
- name: Fail if actions taken
if: steps.action_black.outputs.is_formatted == 'true'
run: exit 1
- name: Discord notification
if: ${{ failure() }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "Black formatter reported errors in {{ EVENT_PAYLOAD.pull_request.html_url }} !"
# test:
# name: Pytest the Bot
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@master
# with:
# fetch-depth: 1
# - name: Run Makefile
# run: make test
# - name: Discord notification
# if: ${{ failure() }}
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# uses: Ilshidur/action-discord@master
# with:
# args: "AdminBot Pytest failed!"
build-and-publish-image:
name: Build Registry
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
package:
- admin_bot
- admin_interface
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Extract Version information for ${{ matrix.package }}
id: extract_hash
run: |
echo BUILD_HASH=$(git describe --abbrev=8 --always --tags --dirty) >> $GITHUB_ENV
- name: Get branch name
id: branch-name
uses: tj-actions/[email protected]
- name: Get a docker ready tag
run: |
echo "${{ steps.branch-name.outputs.current_branch }}"
echo "${{ steps.meta.outputs.tags }}"
echo "CUSTOM_TAG=ghcr.io/frc-1721/$(echo ${{ matrix.package }} | sed 's/[A-Z_]\|L&//'):$(echo "${{ steps.branch-name.outputs.current_branch }}" | sed 's/[^a-zA-Z0-9]/-/g; s/[A-Z]/\L&/g')" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ${{ matrix.package }}/
push: true
build-args: |
GIT_COMMIT=${{ env.BUILD_HASH }}
DEBUG=False
tags: ${{ env.CUSTOM_TAG }}
labels: ${{ steps.meta.outputs.labels }}
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "Built and published a new `${{ matrix.package }}` docker image to `${{ env.CUSTOM_TAG }}`!"
gcr-cleaner:
runs-on: "ubuntu-latest"
needs: [build-and-publish-image]
steps:
- name: Clean adminbot
id: clean_adminbot
uses: actions/delete-package-versions@v4
with:
package-name: "adminbot"
package-type: "container"
min-versions-to-keep: 2
delete-only-untagged-versions: "true"
- name: Clean admininterface
id: clean_admininterface
uses: actions/delete-package-versions@v4
with:
package-name: "admininterface"
package-type: "container"
min-versions-to-keep: 2
delete-only-untagged-versions: "true"