-
Notifications
You must be signed in to change notification settings - Fork 9
105 lines (102 loc) · 3.37 KB
/
update-and-validate-manifest.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
name: build and verify manifest
on: [push]
jobs:
filter_for_configs:
name: Filter for configs folder changes
runs-on: ubuntu-latest
outputs:
configs: ${{ steps.filter.outputs.configs }}
steps:
- uses: actions/[email protected]
- name: Set filter
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
configs:
- 'configs/**'
build_manifest:
name: Build manifest
needs: filter_for_configs
if: ${{ needs.filter_for_configs.outputs.configs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Build manifest
uses: jannekem/run-python-script-action@v1
with:
script: |
import os, json
configs = []
entries = os.scandir('configs')
sorted_entries = sorted(entries, key=lambda x: x.name)
for filename in sorted_entries:
with open(filename, mode='r', encoding='utf-8') as file:
configs.append(json.load(file))
with open("manifest.json", mode='w', encoding='utf-8') as f:
f.truncate(0)
json.dump(configs, f)
- name: Upload manifest to workflow artifacts
uses: actions/upload-artifact@v4
with:
name: manifest
path: manifest.json
if-no-files-found: error
retention-days: 1
update_release:
name: Update dev release
needs: [filter_for_configs, build_manifest]
permissions:
contents: write # Allows pushing changes to the repository
attestations: write # Allows adding and updating artifact attestations
if: ${{ needs.filter_for_configs.outputs.configs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download manifest from artifacts
uses: actions/download-artifact@v4
with:
name: manifest
- name: Update dev pre-release
uses: meeDamian/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: dev
tag: dev
allow_override: true
prerelease: true
files: manifest.json
gzip: false
verify_manifest:
name: Verify manifest
needs: [filter_for_configs, build_manifest]
if: ${{ needs.filter_for_configs.outputs.configs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- run: python -m pip install requests
- name: Download manifest from artifacts
uses: actions/download-artifact@v4
with:
name: manifest
- name: Verify manifest
uses: jannekem/run-python-script-action@v1
with:
script: |
import os, requests, json, sys
url = 'https://app.logz.io/telemetry-agent/public/manifest/validate'
with open("./manifest.json", mode='r', encoding='utf-8') as f:
manifest = json.load(f)
response = requests.post(url, json = manifest)
isValid = response.json()['valid']
if isValid != True:
message = (response.json()['message'])
sys.exit(message)
else:
print('Validation pass')