Build and Deploy Site with LinkedIn Sync #50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy Site with LinkedIn Sync | |
| on: | |
| push: | |
| branches: [ main ] | |
| schedule: | |
| # Run daily at 2 AM UTC to sync LinkedIn profile | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| sync-and-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: | | |
| npm install axios cheerio js-yaml | |
| - name: Fetch LinkedIn Profile and Update CV Data | |
| env: | |
| LINKEDIN_PROFILE_URL: ${{ secrets.LINKEDIN_PROFILE_URL || 'https://www.linkedin.com/in/notawar' }} | |
| PROXYCURL_API_KEY: ${{ secrets.PROXYCURL_API_KEY }} | |
| run: | | |
| node scripts/sync-linkedin.js | |
| - name: Commit updated profile data | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add _data/profile.yml | |
| git diff --staged --quiet || git commit -m "Auto-sync: Update profile from LinkedIn [skip ci]" | |
| git push || echo "No changes to commit" | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.1' | |
| bundler-cache: true | |
| - name: Build Jekyll site | |
| run: bundle exec jekyll build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _site | |
| deploy: | |
| needs: sync-and-build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |