Skip to content

Commit abc5ac1

Browse files
updated secret name
1 parent 2bae6b5 commit abc5ac1

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

.github/workflows/generate-profiles.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
3838
- name: Generate profile images
3939
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
IMAGE_TOKEN: ${{ secrets.IMAGE_TOKEN }}
4141
run: |
4242
# Install required dependencies
4343
npm install node-fetch@2
@@ -50,26 +50,26 @@ jobs:
5050
5151
// Get the API URL from environment variables
5252
const API_URL = process.env.API_URL || 'http://localhost:3000';
53-
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
53+
const IMAGE_TOKEN = process.env.IMAGE_TOKEN;
5454
5555
async function generateProfileImage(username, userId) {
5656
try {
5757
console.log(`Generating image for ${username}...`);
58-
58+
5959
// First, get the user data from GitHub API
6060
const userResponse = await fetch(`https://api.github.com/users/${username}`, {
6161
headers: {
62-
'Authorization': `token ${GITHUB_TOKEN}`,
62+
'Authorization': `token ${IMAGE_TOKEN}`,
6363
'Accept': 'application/vnd.github.v3+json'
6464
}
6565
});
66-
66+
6767
if (!userResponse.ok) {
6868
throw new Error(`GitHub API error: ${userResponse.statusText}`);
6969
}
70-
70+
7171
const userData = await userResponse.json();
72-
72+
7373
// Prepare the data for the OpenReadme API
7474
// Build the API URL with all parameters
7575
const params = new URLSearchParams({
@@ -81,10 +81,10 @@ jobs:
8181
p: userData.blog || userData.html_url,
8282
t: 'classic' // Default theme
8383
});
84-
84+
8585
const apiUrl = `${API_URL}?${params.toString()}`;
8686
console.log(`Calling API: ${apiUrl}`);
87-
87+
8888
// Call the OpenReadme API with proper headers
8989
const response = await fetch(apiUrl, {
9090
method: 'GET',
@@ -93,7 +93,7 @@ jobs:
9393
'Content-Type': 'application/json'
9494
}
9595
});
96-
96+
9797
console.log(`Response status: ${response.status} ${response.statusText}`);
9898
9999
if (!response.ok) {
@@ -103,9 +103,9 @@ jobs:
103103
104104
const result = await response.json();
105105
console.log(`✅ Successfully generated image for ${username}: ${result.url}`);
106-
106+
107107
return result.url;
108-
108+
109109
} catch (error) {
110110
console.error(`❌ Error generating image for ${username}:`, error.message);
111111
return null;
@@ -116,49 +116,49 @@ jobs:
116116
(async () => {
117117
const mappings = process.env.MAPPINGS.split(' ');
118118
console.log(`Found ${mappings.length} users to process`);
119-
119+
120120
for (const mapping of mappings) {
121121
if (!mapping) continue;
122-
122+
123123
const [username, userId] = mapping.split('=');
124124
if (!username || !userId) continue;
125-
125+
126126
console.log(`\n--- Processing ${username} (${userId}) ---`);
127-
127+
128128
try {
129129
const imageUrl = await generateProfileImage(username, userId);
130130
if (imageUrl) {
131131
// Here you could update the user-mapping.json with the new image URL if needed
132132
console.log(`Image URL: ${imageUrl}`);
133133
}
134-
134+
135135
// Add delay to avoid rate limiting (1 second between requests)
136136
await new Promise(resolve => setTimeout(resolve, 1000));
137-
137+
138138
} catch (error) {
139139
console.error(`Error processing ${username}:`, error);
140140
}
141141
}
142-
142+
143143
console.log('\n--- All users processed ---');
144144
})();
145145
EOL
146146
147147
# Run the generation script
148148
MAPPINGS="${{ steps.user-mappings.outputs.mappings }}" \
149149
API_URL="https://openreadme.vercel.app/api/openreadme" \
150-
GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" \
150+
IMAGE_TOKEN="${{ secrets.IMAGE_TOKEN }}" \
151151
node generate-images.js
152152
153153
- name: Commit and push changes
154154
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
155155
env:
156-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156+
IMAGE_TOKEN: ${{ secrets.IMAGE_TOKEN }}
157157
run: |
158158
git config --global user.name "github-actions[bot]"
159159
git config --global user.email "[email protected]"
160160
git config --global --add safe.directory /github/workspace
161161
git add .
162162
git diff --quiet && git diff --staged --quiet || \
163163
(git commit -m "chore: update profile images [skip ci]" && \
164-
git push https://${{ github.actor }}:$GITHUB_TOKEN@github.com/${{ github.repository }}.git HEAD:main)
164+
git push https://${{ github.actor }}:$IMAGE_TOKEN@github.com/${{ github.repository }}.git HEAD:main)

0 commit comments

Comments
 (0)