-
Notifications
You must be signed in to change notification settings - Fork 1.2k
79 lines (68 loc) · 2.41 KB
/
upload-critical.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
name: Upload critical file to R2
on:
workflow_dispatch:
push:
branches:
- master
paths:
- critical
concurrency:
cancel-in-progress: true
group: upload-critical
jobs:
upload:
runs-on: ubuntu-latest
name: Upload
steps:
- name: Checkout the repository
uses: actions/checkout@v4.2.2
- name: Validate with JSON schema
uses: cardinalby/schema-validator-action@3.1.1
with:
file: 'critical'
schema: 'tools/jsonschema/critical.schema.json'
- name: Set up Python
uses: actions/setup-python@v5.3.0
id: python
with:
python-version: "3.x"
- name: Install AWS CLI
run: |
pip3 install \
--disable-pip-version-check \
--ignore-installed \
awscli
- name: Handle the critical file
run: |
mkdir -p upload/critical
jq -c . < critical > upload/critical/data.json
jq -c '[.[].repository]' < critical > upload/critical/repositories.json
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: critical
path: upload/critical
if-no-files-found: error
- name: Upload to R2
run: |
aws s3 sync \
upload/critical \
s3://data-v2/critical \
--endpoint-url ${{ secrets.CF_R2_ENDPOINT_DATA }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_SECRET_ACCESS_KEY }}
- name: Bust Cloudflare cache
run: |
curl --silent --show-error --fail -X POST \
"https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE_ID }}/purge_cache" \
-H "Authorization: Bearer ${{ secrets.CF_BUST_CACHE_TOKEN }}" \
-H "Content-Type: application/json" \
--data '{"files": ["https:\/\/data-v2.hacs.xyz\/critical\/data.json", "https:\/\/data-v2.hacs.xyz\/critical\/repositories.json"]}'
- name: Discord notification
if: ${{ github.event_name == 'schedule' && failure() }}
run: |
curl \
-H "Content-Type: application/json" \
-d '{"username": "GitHub action failure", "content": "[Scheduled action failed!](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})"}' \
${{ secrets.DISCORD_WEBHOOK_ACTION_FAILURE }}