Skip to content

Regenerate Asset Data and PR #536

Regenerate Asset Data and PR

Regenerate Asset Data and PR #536

Workflow file for this run

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."