-
Notifications
You must be signed in to change notification settings - Fork 31
101 lines (85 loc) · 5.46 KB
/
run_docker_macos_workflow.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
name: macOS and iOS SOFA Scan
on:
schedule:
# Monday, Tuesday, Thursday, and Friday every 1 hour from 5:00 PM to 8:00 PM CET
- cron: '0 17-20 * * 1,2,3,4,5'
# On every day every 4 hours
- cron: '30 */4 * * *'
workflow_dispatch:
jobs:
build-and-run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build Docker image
run: docker build . -t sofa_scan
- name: Run Docker container with macOS and iOS arguments
run: |
docker run --name sofa_scan_container \
-e TIMESTAMP_FILE_PATH=/app/v1/timestamp.json \
-v $(pwd)/v1:/app/v1 sofa_scan macOS iOS
- name: Copy resulting JSON files from container to host
run: |
docker cp sofa_scan_container:/app/v1/timestamp.json v1/. || echo "Failed to copy timestamp.json"
docker cp sofa_scan_container:/app/macos_data_feed.json v1/. || true
docker cp sofa_scan_container:/app/ios_data_feed.json v1/. || true
docker cp sofa_scan_container:/app/rss_feed.xml v1/. || true
docker cp sofa_scan_container:/app/cache . || echo "Failed to copy cache files"
docker cp sofa_scan_container:/app/time-series.csv .
- name: List contents of v1
run: ls -la v1/
- name: Copy v1 data feed files into public dir for VitePress
run: |
mkdir -p public/v1
cp -r v1/*.json public/v1/
cp -r v1/*.xml public/v1/
- name: Commit and push if changes are detected
run: |
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add v1/*.json v1/*.xml cache/*.json time-series.csv
git add public/v1/*.json public/v1/*.xml
git commit -m "Update SOFA data - $timestamp" -a || exit 0
git push
- name: Un prettify jsons
run: |
jq -c . v1/ios_data_feed.json > v1/ios_data_feed_jq.json
rm -f v1/ios_data_feed.json
mv v1/ios_data_feed_jq.json v1/ios_data_feed.json
jq -c . v1/macos_data_feed.json > v1/macos_data_feed_jq.json
rm -f v1/macos_data_feed.json
mv v1/macos_data_feed_jq.json v1/macos_data_feed.json
jq -c . v1/timestamp.json > v1/timestamp_jq.json
rm -f v1/timestamp.json
mv v1/timestamp_jq.json v1/timestamp.json
- name: Set up S3cmd cli tool
uses: s3-actions/s3cmd@ef6ce583c6f4e5c121c53777f2f17740c36243be #v1.6.1
with:
provider: digitalocean
region: 'nyc3'
access_key: ${{ secrets.DO_S3_ACCESS_KEY }}
secret_key: ${{ secrets.DO_S3_SECRET_KEY }}
- name: Create gzipped jsons
run: |
/usr/bin/gzip --best --stdout v1/ios_data_feed.json > v1/ios_data_feed_compressed.json
/usr/bin/gzip --best --stdout v1/macos_data_feed.json > v1/macos_data_feed_compressed.json
/usr/bin/gzip --best --stdout v1/timestamp.json > v1/timestamp_compressed.json
- name: Upload to Digital Ocean (Beta Feed)
run: |
s3cmd put v1/ios_data_feed.json --mime-type 'application/json' --acl-public s3://sofafeed.macadmins.io/beta/v1/ios_data_feed_uncompressed.json
s3cmd put v1/macos_data_feed.json --mime-type 'application/json' --acl-public s3://sofafeed.macadmins.io/beta/v1/macos_data_feed_uncompressed.json
s3cmd put v1/timestamp.json --mime-type 'application/json' --acl-public s3://sofafeed.macadmins.io/beta/v1/timestamp_uncompressed.json
s3cmd put v1/ios_data_feed_compressed.json --mime-type 'application/json' --add-header='Content-Encoding:gzip' --add-header='Cache-control:public, no-transform' --acl-public s3://sofafeed.macadmins.io/beta/v1/ios_data_feed.json
s3cmd put v1/macos_data_feed_compressed.json --mime-type 'application/json' --add-header='Content-Encoding:gzip' --add-header='Cache-control:public, no-transform' --acl-public s3://sofafeed.macadmins.io/beta/v1/macos_data_feed.json
s3cmd put v1/timestamp_compressed.json --mime-type 'application/json' --add-header='Content-Encoding:gzip' --add-header='Cache-control:public, no-transform' --acl-public s3://sofafeed.macadmins.io/beta/v1/timestamp.json
- name: Upload to Digital Ocean (Production Feed)
run: |
s3cmd put v1/ios_data_feed.json --mime-type 'application/json' --acl-public s3://sofafeed.macadmins.io/v1/ios_data_feed_uncompressed.json
s3cmd put v1/macos_data_feed.json --mime-type 'application/json' --acl-public s3://sofafeed.macadmins.io/v1/macos_data_feed_uncompressed.json
s3cmd put v1/timestamp.json --mime-type 'application/json' --acl-public s3://sofafeed.macadmins.io/v1/timestamp_uncompressed.json
s3cmd put v1/ios_data_feed_compressed.json --mime-type 'application/json' --add-header='Content-Encoding:gzip' --add-header='Cache-control:public, no-transform' --acl-public s3://sofafeed.macadmins.io/v1/ios_data_feed.json
s3cmd put v1/macos_data_feed_compressed.json --mime-type 'application/json' --add-header='Content-Encoding:gzip' --add-header='Cache-control:public, no-transform' --acl-public s3://sofafeed.macadmins.io/v1/macos_data_feed.json
s3cmd put v1/timestamp_compressed.json --mime-type 'application/json' --add-header='Content-Encoding:gzip' --add-header='Cache-control:public, no-transform' --acl-public s3://sofafeed.macadmins.io/v1/timestamp.json
s3cmd put v1/rss_feed.xml --mime-type 'application/xml' --add-header='Cache-control:public, no-transform' --acl-public s3://sofafeed.macadmins.io/v1/rss_feed.xml