-
Notifications
You must be signed in to change notification settings - Fork 200
89 lines (76 loc) · 2.81 KB
/
generate.yml
File metadata and controls
89 lines (76 loc) · 2.81 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
name: Regenerate Asset Data and PR
on:
# Allows manual triggering if we ever want to
workflow_dispatch:
schedule:
- cron: '0 9 * * *' # 9AM UTC every day
permissions:
contents: write
pull-requests: write
jobs:
check-existing-pr:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check_pr.outputs.skip }}
steps:
- name: Check for existing PR
id: check_pr
env:
GH_TOKEN: ${{ github.token }}
run: |
EXISTING_PR=$(gh pr list --repo "${{ github.repository }}" --head feat_regenerate_asset_data --base develop --state open --json number --jq '.[0].number')
if [ -n "$EXISTING_PR" ]; then
echo "Open PR #$EXISTING_PR already exists, skipping regeneration"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "No existing PR found, proceeding with regeneration"
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
regenerate-and-create-pr:
needs: check-existing-pr
if: needs.check-existing-pr.outputs.skip == 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout develop
uses: actions/checkout@v4
with:
ref: develop
- name: Setup pnpm
run: corepack enable && corepack prepare pnpm@10.30.3 --activate
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Cache node_modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-node-modules-
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build Packages
run: pnpm run build:packages
- name: Generate all assets
env:
ZERION_API_KEY: ${{ secrets.ZERION_API_KEY }}
COINCAP_API_KEY: ${{ secrets.COINCAP_API_KEY }}
run: pnpm run generate:all
- name: Create new feature branch
run: git checkout -B feat_regenerate_asset_data
- name: Commit changes
run: |
git checkout -B feat_regenerate_asset_data
git config --local user.email "action@github.com"
git config --local user.name "asset-generation-bot"
git add -A
CURRENT_DATE=$(date +'%m/%d/%Y')
git diff --staged --quiet || git commit -m "feat: regenerate asset data $CURRENT_DATE"
git push -u origin feat_regenerate_asset_data -f
- name: Create Pull Request
env:
GH_TOKEN: ${{ github.token }}
run: |
CURRENT_DATE=$(date +'%m/%d/%Y')
gh pr create --base develop --head feat_regenerate_asset_data --title "feat: regenerate asset data $CURRENT_DATE" --body "Generated from CI."