-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (65 loc) · 2.68 KB
/
Copy pathvalidate-commit.yml
File metadata and controls
79 lines (65 loc) · 2.68 KB
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
name: validate-commit
on: [push]
jobs:
validate-commit:
runs-on: ubuntu-latest
steps:
- name: Report branch info
run: echo "Detected push to ${{ github.ref_name }} by $GITHUB_ACTOR"
- name: Check out repository code
uses: actions/checkout@v4
- name: Validate the plugin
id: validate
continue-on-error: true
run: |
set -o pipefail
set +e
cd scripts && python3 missingCardFinder.py > output.txt 2>&1
EXIT_CODE=$?
set -e
FILESIZE=$(wc -c < output.txt)
if [ "$EXIT_CODE" -ne 0 ] || [ "$FILESIZE" -ne 0 ]; then
echo "failed=true" >> "$GITHUB_OUTPUT"
else
echo "failed=false" >> "$GITHUB_OUTPUT"
fi
echo "filesize=$FILESIZE" >> "$GITHUB_OUTPUT"
cat output.txt
- name: Find Discord user
if: always()
id: discord
run: |
USERCODE=$(jq -r --arg actor "$GITHUB_ACTOR" '.[$actor]' .github/workflows/usernames.json)
echo "discord_name=$USERCODE" >> "$GITHUB_OUTPUT"
- name: Check previous workflow result
if: always()
id: previous
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PREV_CONCLUSION=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${{ github.repository }}/actions/workflows/validate-commit.yml/runs?branch=${{ github.ref_name }}" | jq -r '.workflow_runs[1].conclusion')
if [ "$PREV_CONCLUSION" = "failure" ]; then
echo "previous_failed=true" >> "$GITHUB_OUTPUT"
else
echo "previous_failed=false" >> "$GITHUB_OUTPUT"
fi
- name: Send error discord message
if: always() && steps.validate.outputs.failed == 'true'
uses: tsickert/discord-webhook@v4.0.0
with:
webhook-url: ${{ secrets.validationWebhook }}
filename: scripts/output.txt
content: >
Hey ${{ steps.discord.outputs.discord_name }},
there was a problem validating your last plugin commit
on branch `${{ github.ref_name }}`.
- name: Send success discord message
if: always() && steps.validate.outputs.failed == 'false' && steps.previous.outputs.previous_failed == 'true'
uses: tsickert/discord-webhook@v4.0.0
with:
webhook-url: ${{ secrets.validationWebhook }}
content: >
All of the issues on branch `${{ github.ref_name }}` are now fixed! 🎉
- name: Fail workflow if plugin failed
if: always() && steps.validate.outputs.failed == 'true'
run: exit 1