|
| 1 | +name: Build and Deploy Site with LinkedIn Sync |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + schedule: |
| 7 | + # Run daily at 2 AM UTC to sync LinkedIn profile |
| 8 | + - cron: '0 2 * * *' |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + pages: write |
| 14 | + id-token: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + sync-and-build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Setup Node.js |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: '20' |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: | |
| 30 | + npm install axios cheerio js-yaml |
| 31 | +
|
| 32 | + - name: Fetch LinkedIn Profile and Update CV Data |
| 33 | + env: |
| 34 | + LINKEDIN_PROFILE_URL: ${{ secrets.LINKEDIN_PROFILE_URL || 'https://www.linkedin.com/in/notawar' }} |
| 35 | + PROXYCURL_API_KEY: ${{ secrets.PROXYCURL_API_KEY }} |
| 36 | + run: | |
| 37 | + node scripts/sync-linkedin.js |
| 38 | +
|
| 39 | + - name: Commit updated profile data |
| 40 | + run: | |
| 41 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 42 | + git config --local user.name "github-actions[bot]" |
| 43 | + git add _data/profile.yml |
| 44 | + git diff --staged --quiet || git commit -m "Auto-sync: Update profile from LinkedIn [skip ci]" |
| 45 | + git push || echo "No changes to commit" |
| 46 | +
|
| 47 | + - name: Setup Ruby |
| 48 | + uses: ruby/setup-ruby@v1 |
| 49 | + with: |
| 50 | + ruby-version: '3.1' |
| 51 | + bundler-cache: true |
| 52 | + |
| 53 | + - name: Build Jekyll site |
| 54 | + run: bundle exec jekyll build |
| 55 | + |
| 56 | + - name: Upload artifact |
| 57 | + uses: actions/upload-pages-artifact@v3 |
| 58 | + with: |
| 59 | + path: _site |
| 60 | + |
| 61 | + deploy: |
| 62 | + needs: sync-and-build |
| 63 | + runs-on: ubuntu-latest |
| 64 | + environment: |
| 65 | + name: github-pages |
| 66 | + url: ${{ steps.deployment.outputs.page_url }} |
| 67 | + steps: |
| 68 | + - name: Setup Pages |
| 69 | + uses: actions/configure-pages@v4 |
| 70 | + |
| 71 | + - name: Deploy to GitHub Pages |
| 72 | + id: deployment |
| 73 | + uses: actions/deploy-pages@v4 |
0 commit comments