-
Notifications
You must be signed in to change notification settings - Fork 5
91 lines (77 loc) · 2.97 KB
/
generate-artifacts.yml
File metadata and controls
91 lines (77 loc) · 2.97 KB
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
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"