macOS and iOS SOFA Scan #2474
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |