-
Notifications
You must be signed in to change notification settings - Fork 469
171 lines (157 loc) · 6.19 KB
/
detect-new-tokens.yml
File metadata and controls
171 lines (157 loc) · 6.19 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Detect New CCIP Tokens
# This workflow runs on a schedule to detect newly supported tokens in CCIP configuration.
# It performs the following tasks:
# 1. Runs the detect-new-tokens.ts script which:
# - Compares current token configuration with a historical state
# - Identifies newly supported tokens and expanded token support
# - Validates token URLs (documentation and icons)
# - Generates a changelog entry for new tokens
# 2. Processes the results using modular bash scripts to:
# - Create GitHub issues for validation failures or script errors
# - Generate pull requests with changelog updates
#
# Requirements:
# - Node.js environment with npm dependencies
# - Git history access for historical comparisons (fetch-depth: 0)
# - Write permissions for issues, PRs, and repository contents
on:
schedule:
# Run every Sunday at 9:00 PM UTC
- cron: '0 21 * * 0'
workflow_dispatch: # Allow manual triggering
# Cancel any in-progress job or run
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
issues: write # Required for creating issues
pull-requests: write
contents: write
# Configurable paths and settings as environment variables
env:
SCRIPTS_PATH: .github/scripts/ccip
TEMP_DIR: temp
NODE_VERSION: '20'
jobs:
# Setup job to install and cache dependencies
setup:
name: Setup Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history for git operations
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
# Cache node_modules to speed up future runs
- name: Cache node_modules
uses: actions/cache@v4
id: cache-node-modules
with:
path: |
node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
echo "Cache miss, installing dependencies..."
npm ci --prefer-offline --no-audit
# Main job to detect new tokens
detect-new-tokens:
needs: setup
name: Check for New CCIP Tokens
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history for git operations
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
# Restore node_modules from setup job
- name: Restore node_modules
uses: actions/cache@v4
with:
path: |
node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
# Verify the helper scripts are executable
- name: Ensure scripts are executable
run: chmod +x ${{ env.SCRIPTS_PATH }}/*.sh
# Run main token detection script
- name: Run token detection script
id: detect_tokens
run: |
npm run detect-new-tokens
echo "exit_code=$?" >> $GITHUB_OUTPUT
continue-on-error: true
# Check for script execution errors
- name: Check for script errors
id: check_errors
if: steps.detect_tokens.outcome != 'success' || steps.detect_tokens.outputs.exit_code != '0'
run: ${{ env.SCRIPTS_PATH }}/detect-tokens.sh check-errors "${{ steps.detect_tokens.outputs.exit_code || 'unknown' }}" "${{ steps.detect_tokens.outputs.stderr || 'No detailed error information available' }}"
# Create issue for script failures
- name: Create Issue for Script Failure
if: steps.check_errors.outputs.script_failed == 'true'
uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5.0.1
with:
title: "Error: CCIP Token Detection Script Failed"
content-filepath: ${{ env.TEMP_DIR }}/error_report.md
labels: |
bug
automation
# Process detected tokens
- name: Check if new tokens detected
id: check_tokens
if: steps.detect_tokens.outcome == 'success' && steps.detect_tokens.outputs.exit_code == '0'
run: ${{ env.SCRIPTS_PATH }}/detect-tokens.sh check-tokens
# Create issue for URL validation failures
- name: Create Issue for URL Validation Failures
if: steps.check_tokens.outputs.url_validation_failed == 'true'
uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5.0.1
with:
title: "Warning: Invalid Token URLs Detected"
content-filepath: ${{ env.TEMP_DIR }}/url_validation_report.md
labels: |
bug
documentation
priority:high
# Create PR for new tokens
- name: Create PR with new token information
if: steps.check_tokens.outputs.new_tokens_found == 'true'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "CCT: Update changelog with new tokens"
branch: "ccip-tokens/update-${{ steps.check_tokens.outputs.timestamp }}"
delete-branch: true
title: "Update CCT Changelog: New CCIP Tokens Detected"
body-path: ${{ env.TEMP_DIR }}/newTokensReport.md
add-paths: |
public/changelog.json
labels: |
documentation
enhancement
# Capture output artifacts (always runs, even if previous steps failed)
- name: Capture output files
if: always()
uses: actions/upload-artifact@v4
with:
name: token-detection-artifacts-${{ github.run_id }}
path: |
${{ env.TEMP_DIR }}/*.json
${{ env.TEMP_DIR }}/*.md
public/changelog.json
retention-days: 14
if-no-files-found: ignore