-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (33 loc) · 1.29 KB
/
run_black.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
name: Run Black Formatter
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- name: Add label if failure
if: failure()
run: |
curl --request POST \
--url "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" \
--header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
--header "Content-Type: application/json" \
--data-raw '{"labels": ["Formatter Failed"]}'
- name: Check and remove label if sucess
if: success()
run: |
labels=$(curl -s \
--request GET \
--url "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" \
--header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}")
if [[ $labels == *"Formatter Failed"* ]]; then
curl --request DELETE \
--url "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/Formatter%20Failed" \
--header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"
fi