Feature List #26
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: Feature List | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '30 0 * * *' | |
permissions: | |
contents: write | |
actions: read | |
jobs: | |
trigger-feature-list: | |
runs-on: ubuntu-latest | |
env: | |
FEATURES_FILE: 'src/sections/Pricing/feature_data.json' | |
SPREADSHEET_URL: 'http://docs.google.com/spreadsheets/d/1Ck_5q7U_vLSIDTtplugG3pCVC5zugXgTHtO7T7-yL8g/export?format=csv&gid=829069645&single=true&output=csv' | |
steps: | |
- name: Checkout current repository | |
uses: actions/checkout@v4 | |
- name: Restore cache | |
id: cache-sha | |
uses: actions/cache@v3 | |
with: | |
path: .sha-cache | |
key: feature-data-sha | |
restore-keys: | | |
feature-data-sha | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: | | |
npm install csvtojson --legacy-peer-deps | |
- name: Fetch spreadsheet and check for updates | |
run: | | |
# Download the spreadsheet | |
curl -L $SPREADSHEET_URL -o spreadsheet.csv | |
# Generate a SHA hash of the file | |
sha256sum spreadsheet.csv > .sha-cache/latest-sha | |
# Compare the hash with the previously stored hash | |
if [ -f ".sha-cache/last-sha" ] && cmp --silent .sha-cache/latest-sha .sha-cache/last-sha; then | |
echo "No updates detected." | |
echo "has-updates=false" >> $GITHUB_OUTPUT | |
else | |
echo "Updates detected. Processing..." | |
cp .sha-cache/latest-sha .sha-cache/last-sha | |
# Convert CSV to JSON (Assume a script or tool to do this is present) | |
node -e " | |
const fs = require('fs'); | |
const csv = require('csvtojson'); | |
csv() | |
.fromFile('spreadsheet.csv') | |
.then(json => fs.writeFileSync(process.env.FEATURES_FILE, JSON.stringify(json, null, 2))); | |
" | |
echo "has-updates=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit changes | |
id: commit-changes | |
if: steps.check-updates.outputs.has-updates == 'true' | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "Updated feature data from source repository" | |
file_pattern: ${{ env.FEATURES_FILE }} | |
branch: master | |
commit_options: "--signoff" | |
commit_user_name: l5io | |
commit_user_email: [email protected] | |
commit_author: 'l5io <[email protected]>' | |
call-build-and-deploy--workflow: | |
needs: | |
- trigger-feature-list | |
name: Build and Deploy Site | |
uses: layer5io/layer5/.github/workflows/build-and-deploy-site.yml@master | |
secrets: inherit |