Manual build #216
This file contains 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: Manual build | |
on: | |
schedule: | |
- cron: '15 6 * * *' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Conditionally deploy | |
uses: actions/github-script@v7 | |
env: | |
NETLIFY_BUILD_HOOK_URL: ${{ secrets.NETLIFY_BUILD_HOOK_URL }} | |
with: | |
script: | | |
const CURRENT_DATE = new Date().toISOString().slice(0, 10) | |
const response = await fetch('https://www.raygesualdo.com/api/publish-dates.json') | |
const dates = await response.json() | |
core.startGroup('Data') | |
core.info(`CURRENT_DATE: ${CURRENT_DATE}`) | |
core.info(`dates:\n${JSON.stringify(dates, null, 2)}`) | |
core.endGroup() | |
if (dates.includes(CURRENT_DATE) && process.env.NETLIFY_BUILD_HOOK_URL) { | |
console.log( | |
'A post scheduled for today was found. Triggering a Netlify build.' | |
) | |
await fetch(process.env.NETLIFY_BUILD_HOOK_URL, { method: 'POST' }) | |
} |