-
Notifications
You must be signed in to change notification settings - Fork 9
89 lines (78 loc) · 2.85 KB
/
update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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