Build and Deploy WTF Just Happened Today? Jekyll Site #590
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 WTF Just Happened Today? Jekyll Site | |
| on: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| - cron: '0 9 * * *' # daily at 9 AM UTC (2 AM PT / 5 AM ET) | |
| workflow_dispatch: # allow manual triggering | |
| jobs: | |
| build-deploy: | |
| runs-on: ubuntu-latest | |
| env: | |
| JEKYLL_ENV: production | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.3.5 | |
| bundler-cache: true | |
| - name: Install bundler and configure | |
| run: | | |
| gem install bundler -v 2.6.6 | |
| bundle config set path 'vendor/bundle' | |
| bundle config set force_ruby_platform true | |
| ruby -v | |
| bundler -v | |
| gem -v | |
| gem environment | |
| - name: Install dependencies | |
| run: | | |
| bundle lock --add-platform ruby | |
| bundle install --jobs=3 --retry=3 | |
| bundle clean --force | |
| - name: Run cron build (Algolia) | |
| if: github.event_name == 'schedule' | |
| run: | | |
| JEKYLL_ENV=production ALGOLIA_API_KEY=${{ secrets.ALGOLIA_API_KEY }} ALGOLIA_APPLICATION_ID=${{ secrets.ALGOLIA_APPLICATION_ID }} bundle exec jekyll algolia | |
| shell: bash | |
| - name: Run regular build | |
| if: github.event_name != 'schedule' | |
| run: bundle exec jekyll build --trace | |
| shell: bash | |
| - name: Deploy to S3 | |
| if: github.event_name != 'schedule' | |
| uses: reggionick/s3-deploy@v4 | |
| with: | |
| folder: _site | |
| bucket: whatthefuckjusthappenedtoday.com | |
| bucket-region: us-east-1 | |
| delete-removed: false | |
| no-cache: true | |
| private: false | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| - name: Purge Cloudflare cache | |
| if: github.event_name != 'schedule' | |
| run: | | |
| curl -X DELETE "https://api.cloudflare.com/client/v4/zones/2fa02b93146397fbf2001d812ab8b31f/purge_cache" \ | |
| -H "X-Auth-Email: ${{ secrets.CLOUD_FLARE_EMAIL }}" \ | |
| -H "X-Auth-Key: ${{ secrets.CLOUD_FLARE_API_KEY }}" \ | |
| -H "Content-Type: application/json" \ | |
| --data '{"purge_everything":true}' | |
| - name: Ping search engines and Internet Archive | |
| if: github.event_name != 'schedule' | |
| run: | | |
| curl http://www.bing.com/ping?sitemap=https://whatthefuckjusthappenedtoday.com/sitemap.xml | |
| - name: Ping WebSub hub | |
| run: | | |
| HUB=https://pubsubhubbub.appspot.com/ | |
| BASE=https://whatthefuckjusthappenedtoday.com | |
| curl -s -X POST "$HUB" -d "hub.mode=publish" \ | |
| -d "hub.url=$BASE/rss.xml" \ | |
| -d "hub.url=$BASE/atom.xml" \ | |
| -d "hub.url=$BASE/feed.json" | |
| - name: Notify Slack | |
| if: always() | |
| uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| SLACK_USERNAME: WTFJHT Bot | |
| SLACK_ICON_EMOJI: ':newspaper:' | |
| SLACK_TITLE: GitHub Actions Build | |
| SLACK_COLOR: ${{ job.status == 'success' && '#36a64f' || '#ff0000' }} | |
| SLACK_MESSAGE: "${{ github.workflow }} #${{ github.run_number }} by ${{ github.actor }} - ${{ job.status }}" |