Fetch Facebook Posts #7
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: Fetch Facebook Posts | |
| on: | |
| schedule: | |
| # Run every Monday at 9:00 AM UTC | |
| - cron: '0 9 * * 1' | |
| workflow_dispatch: | |
| jobs: | |
| fetch-posts: | |
| runs-on: ubicloud-standard-8 | |
| permissions: | |
| actions: write | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Fetch Facebook Posts | |
| env: | |
| APIFY_API_TOKEN: ${{ secrets.APIFY_API_TOKEN }} | |
| run: | | |
| bun scripts/fetch-facebook-posts.js | |
| - name: Check for changes | |
| id: verify-changed-files | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push changes | |
| if: steps.verify-changed-files.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add social-posts/ images/facebook-posts/ | |
| git commit -m "Auto-update: Fetch new Facebook posts" | |
| git push | |
| - name: Rebuild site | |
| if: steps.verify-changed-files.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh workflow run build-and-deploy.yml --ref "$GITHUB_REF_NAME" |