Skip to content

Trigger Site Rebuild on a CRON Schedule #1363

Trigger Site Rebuild on a CRON Schedule

Trigger Site Rebuild on a CRON Schedule #1363

name: Trigger Site Rebuild on a CRON Schedule
on:
schedule:
- cron: '1 */12 * * *' # "At minute 1 past every 12th hour." (see https://crontab.guru)
jobs:
trigger-deploy:
# prevents this action from running on forks
if: github.repository == 'Roma-JS/roma-js-on-astro'
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎️
uses: 'actions/checkout@v4'
with:
ref: 'release'
token: ${{ secrets.DEPLOY_TOKEN }} # see https://github.com/Roma-JS/roma-js-on-astro/issues/12
- name: Setup environment
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
git config user.name 'cronjob-deploy'
git config user.email '[email protected]'
echo "GIT_DEPLOY_DATE=$(date)" >> $GITHUB_ENV
echo "GIT_DEPLOY_CID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Update site-deploy.yml
run: |
printf 'date: %s\ncid: %s\n' "${{ env.GIT_DEPLOY_DATE }}" "${{ env.GIT_DEPLOY_CID }}" > site-deploy.yml
- name: Commit and push changes
run: |
git add site-deploy.yml
git commit -m "cronjob deploy 🚀 of ${{ env.GIT_DEPLOY_CID }} at ${{ env.GIT_DEPLOY_DATE }}"
git push origin release