@@ -10,6 +10,7 @@ permissions:
1010 contents : write # Required for pushing changes
1111 pull-requests : write # Required for creating pull requests
1212 packages : read # Required for reading package information
13+ actions : read
1314
1415jobs :
1516 generate-images :
3940
4041 - name : Generate profile images
4142 env :
42- IMAGE_TOKEN : ${{ secrets.IMAGE_TOKEN }}
43+ GITHUB_REPOSITORY : ${{ github.repository }}
44+ GITHUB_REPOSITORY_OWNER : ${{ github.repository_owner }}
45+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN || secrets.IMAGE_TOKEN }}
4346 run : |
4447 # Install required dependencies
4548 npm install node-fetch@2
5255
5356 // Get the API URL from environment variables
5457 const API_URL = process.env.API_URL || 'http://localhost:3000';
55- const IMAGE_TOKEN = process.env.IMAGE_TOKEN ;
58+ const GITHUB_TOKEN = process.env.GITHUB_TOKEN ;
5659
5760 async function generateProfileImage(username, userId) {
5861 try {
6164 // First, get the user data from GitHub API
6265 const userResponse = await fetch(`https://api.github.com/users/${username}`, {
6366 headers: {
64- 'Authorization': `token ${IMAGE_TOKEN }`,
67+ 'Authorization': `token ${GITHUB_TOKEN }`,
6568 'Accept': 'application/vnd.github.v3+json'
6669 }
6770 });
@@ -73,14 +76,13 @@ jobs:
7376 const userData = await userResponse.json();
7477
7578 // Prepare the data for the OpenReadme API
76- // Build the API URL with all parameters
7779 const params = new URLSearchParams({
7880 n: userData.name || username,
7981 i: userData.avatar_url || '',
8082 github: username,
8183 x: userData.twitter_username || '',
82- l: '', // LinkedIn would need to be handled separately
83- p: userData.blog || userData. html_url,
84+ l: userData.blog || userData.html_url,
85+ p: userData.html_url,
8486 t: 'classic' // Default theme
8587 });
8688
@@ -149,20 +151,19 @@ jobs:
149151 # Run the generation script
150152 MAPPINGS="${{ steps.user-mappings.outputs.mappings }}" \
151153 API_URL="https://openreadme.vercel.app/api/openreadme" \
152- IMAGE_TOKEN="${{ secrets.IMAGE_TOKEN }}" \
153154 node generate-images.js
154155
155156 - name : Pull latest changes
156157 run : git pull origin main --rebase
157158 - name : Commit and push changes
158159 if : github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
159160 env :
160- IMAGE_TOKEN : ${{ secrets.IMAGE_TOKEN }}
161+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN || secrets.IMAGE_TOKEN }}
161162 run : |
162163 git config --global user.name "github-actions[bot]"
163164 git config --global user.email "[email protected] " 164165 git config --global --add safe.directory /github/workspace
165166 git add .
166167 git diff --quiet && git diff --staged --quiet || \
167168 (git commit -m "chore: update profile images [skip ci]" && \
168- git push https://${{ github.actor }}:$IMAGE_TOKEN @github.com/${{ github.repository }}.git HEAD:main)
169+ git push https://${{ github.actor }}:$GITHUB_TOKEN @github.com/${{ github.repository }}.git HEAD:main)
0 commit comments