Skip to content

Generate Devvit Fixtures and DB #96

Generate Devvit Fixtures and DB

Generate Devvit Fixtures and DB #96

name: 'Generate Devvit Fixtures and DB'
on:
schedule:
- cron: '0 21 * * *'
workflow_dispatch:
jobs:
generate:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
# Use the version declared in .nvmrc if present; otherwise default to 20.x
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Generate chunks
run: npm run scripts:generate-chunks
- name: Generate SQLite DB
run: npm run scripts:generate-sqlite-db
- name: Hash content and compare to latest release
id: hash_and_compare
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run scripts:hash-and-compare
- name: Check if new release is needed
id: check_release
run: |
if [ ${{ steps.hash_and_compare.outcome }} == 'success' ]; then
echo "new_release=true" >> $GITHUB_OUTPUT
else
echo "new_release=false" >> $GITHUB_OUTPUT
fi
- name: Create release tag
id: create_tag
if: steps.check_release.outputs.new_release == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Check if the tag already exists remotely or locally
if git rev-parse "refs/tags/artifacts-${{ steps.date.outputs.date }}" >/dev/null 2>&1 || \
git ls-remote --tags origin | grep -q "refs/tags/artifacts-${{ steps.date.outputs.date }}$"; then
echo "Tag artifacts-${{ steps.date.outputs.date }} already exists. Skipping tag creation."
else
git tag artifacts-${{ steps.date.outputs.date }}
git push origin artifacts-${{ steps.date.outputs.date }}
fi
- name: Create GitHub Release
id: create_release
if: steps.check_release.outputs.new_release == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: artifacts-${{ steps.date.outputs.date }}
name: 'Embeddings Release: artifacts-${{ steps.date.outputs.date }}'
body: 'Regenerated embeddings for artifacts-${{ steps.date.outputs.date }}'
draft: false
prerelease: false
files: |
db/devvit-docs.db
fixtures.tar.gz
- name: Skip release
if: steps.check_release.outputs.new_release == 'false'
run: echo "No new release needed - content has not changed"