Check for docs updates #2134
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: Check for docs updates | |
on: | |
workflow_dispatch: {} | |
repository_dispatch: | |
types: [docs-update] | |
schedule: | |
# run this during the week, tuesday to friday | |
# at 9:10am, 9:10pm | |
# Redmond time (UTC-7) | |
- cron: '10 16,4 * * 2-5' | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: false | |
jobs: | |
check: | |
if: github.repository == 'bedrock-dot-dev/docs' && github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ποΈ | |
uses: actions/checkout@v3 | |
- name: Setup Python π | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Install dependencies βοΈ | |
run: | | |
pip install -r scripts/requirements.txt | |
- name: Setup git environment βοΈ | |
run: | | |
git config --global user.name 'destruc7i0n' | |
git config --global user.email '[email protected]' | |
- name: Check for docs update π | |
id: check | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
cd scripts | |
python3 update.py | |
- name: Update summary π | |
run: | | |
echo "### Check output ποΈ" >> $GITHUB_STEP_SUMMARY | |
echo "Update found: ${{ (steps.check.outputs.update == 'true' && 'β ') || 'β' }}" >> $GITHUB_STEP_SUMMARY | |
echo 'JSON output: `${{ steps.check.outputs.release_data }}`' >> $GITHUB_STEP_SUMMARY | |
if [ "${{ steps.check.outputs.update }}" == "true" ]; then | |
echo 'Commit message: ${{ steps.check.outputs.msg }}' >> $GITHUB_STEP_SUMMARY | |
fi | |
- name: Send Discord message π | |
if: steps.check.outputs.update == 'true' | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
run: | | |
LAST_COMMIT_SHA=$(git rev-parse HEAD) | |
jq -nr '{ | |
"content": null, | |
"embeds": [ | |
{ | |
"title": "Docs update: **${{ steps.check.outputs.msg }}**", | |
"url": "https://github.com/${{ github.repository }}/commit/'"$LAST_COMMIT_SHA"'", | |
} | |
], | |
"username": "bedrock.dev", | |
"avatar_url": "https://bedrock.dev/favicon/android-chrome-512x512.png", | |
}' | curl -X POST -H "Content-Type: application/json" -d @- $DISCORD_WEBHOOK | |
- name: Archive documentation files π | |
if: steps.check.outputs.update == 'true' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.check.outputs.msg }} | |
path: scripts/tmp | |
- name: Deploy site π | |
if: steps.check.outputs.update == 'true' | |
env: | |
VERCEL_DEPLOY_HOOK: ${{ secrets.VERCEL_DEPLOY_HOOK }} | |
run: | | |
# sleep for a bit for GitHub's cache | |
sleep 10s | |
curl -X POST $VERCEL_DEPLOY_HOOK |