-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (115 loc) · 4.22 KB
/
diff.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
name: Production Diff Staging
on:
push:
branches:
- patch-open-issue
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
diff:
runs-on: ubuntu-20.04
env:
AWS_S3_ENDPOINT: ${{ secrets.DO_S3_ENDPOINT }}
AWS_ACCESS_KEY_ID: ${{ secrets.DO_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: edm-publishing
outputs:
matrix: ${{ steps.diff.outputs.matrix }}
notify: ${{ steps.diff.outputs.notify }}
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: ./run.sh install
- name: Compute diff matrix
id: diff
shell: python
run: |
import json
import os
import os
diff=os.popen('./run.sh diff_list').readlines()
diff=[d.replace('\n', '') for d in diff]
diff_json=json.dumps(json.dumps(diff))
print(len(diff))
print(str(len(diff)))
os.system('''echo "::set-output name=notify::{}"'''.format(str(len(diff))))
os.system('''echo "::set-output name=matrix::{}"'''.format(diff_json))
- name: notify?
run: |
echo ${{ steps.diff.outputs.notify }}
- name: Print Matrix
run: |
echo ${{ steps.diff.outputs.matrix }}
- name: test notify
run: echo ${{ steps.diff.outputs.notify }}
- name: test notify
if: steps.diff.outputs.notify != '0'
run: echo ${{ steps.diff.outputs.notify }}
- name: test notify
if: steps.diff.outputs.notify != 0
run: echo ${{ steps.diff.outputs.notify }}
notify:
runs-on: ubuntu-20.04
if: needs.diff.outputs.notify != '0'
needs: [diff]
env:
AWS_S3_ENDPOINT: ${{ secrets.DO_S3_ENDPOINT }}
AWS_ACCESS_KEY_ID: ${{ secrets.DO_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: edm-publishing
strategy:
matrix:
dataset: ${{ fromJSON(needs.diff.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: ./run.sh install
- name: Random Sleep
run: sleep $[ ( $RANDOM % 10 ) + 1 ]s
- name: Get Category
id: category
run: |
category=$(cat metadata.json | jq -r '.[] | select( .name | contains("${{ matrix.dataset }}"))' | jq -r '.category')
echo "::set-output name=category::$category"
- uses: actions/github-script@v3
name: Create Issue to Publish (if it doesn't exist)
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let category;
if ('${{ steps.category.outputs.category }}' === '') {
category = '🚕 Other'
} else {
category = '${{ steps.category.outputs.category }}'
}
const title = `[publish] ${{ matrix.dataset }}`;
const body = `
## Difference Detected Between \`Production\` and \`Staging\` in the following dataset(s)
### Dataset(s)
\`\`\`yml
- ${{ matrix.dataset }}
\`\`\`
### Next Steps
If you have manually checked above files and they seem to be ok, add the \'publish\' label to this issue.
This will allow github actions to move staging files to production.
Feel free to close this issue once it's all complete. Thanks!
`;
const issues = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
const filtered = issues.data.filter(issue => issue.title === title)
if (filtered.length > 0) {
console.log('Issue Already Exists')
} else {
github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
assignees: ["ileoyu", "OmarOrtiz1"],
labels: ['staging', category]
});
}