-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (116 loc) · 3.91 KB
/
main.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: CI
on:
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
changes:
name: 🔎 Determine deployable changes
runs-on: ubuntu-latest
outputs:
DEPLOYABLE: ${{steps.deploy_changes.outputs.DEPLOYABLE}}
CONTENT: ${{steps.content_changes.outputs.CONTENT}}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: "50"
- name: ⎔ Setup node
uses: actions/setup-node@v2
with:
node-version: 18
- name: 🔎 Determine deployable changes
id: deploy_changes
run: >-
echo ::set-output name=DEPLOYABLE::$(node ./scripts/is-deployable.js ${{
github.sha }})
- name: ❓ Deployable
run: >-
echo "DEPLOYABLE: ${{steps.deploy_changes.outputs.DEPLOYABLE}}"
- name: 🔎 Determine content changes
id: content_changes
run: >-
echo ::set-output name=CONTENT::$(node ./scripts/get-changed-content.js ${{
github.sha }})
env:
API_URL: ${{ secrets.API_URL }}
- name: ❓ Content
run: >-
echo "CONTENT: ${{steps.content_changes.outputs.CONTENT}}"
deploy:
name: Deploy
needs: [changes]
if: needs.changes.outputs.DEPLOYABLE == 'true'
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
- name: Deploy a Cloudflare Pages Project
uses: tomjschuster/cloudflare-pages-deploy-action@v0.0.12
with:
account-id: 37f727d1d4626f9f40b9f0f7b66168de
api-key: ${{ secrets.CF_API_KEY }}
email: ${{ secrets.CF_ACCOUNT_EMAIL }}
project-name: itsaydrian
github-token: ${{ secrets.GITHUB_TOKEN }}
production: true
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
- name: 🥶 Cache dependencies
if: $${{ !env.ACT }}
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-npm-
${{ runner.OS }}-
- name: ⎔ Setup node
uses: actions/setup-node@v1
with:
node-version: 18
- name: 📦 Install npm packages
run: cd ./scripts/mdx && npm install
- name: 🚀 Update deploy sha
run: node ./scripts/mdx/update-deploy-sha.js
env:
COMMIT_SHA: ${{ github.sha }}
API_URL: ${{ secrets.API_URL }}
POST_API_KEY: ${{ secrets.POST_API_KEY }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
compile:
name: 🛠 Compile MDX
if: needs.changes.outputs.CONTENT != ''
needs: [changes]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: "50"
- name: ⎔ Setup node
uses: actions/setup-node@v1
with:
node-version: 18
- name: 🥶 Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-npm-
${{ runner.OS }}-
- name: 📦 Install npm packages
run: cd ./scripts/mdx && npm install
- name: 🚀 Compile and post MDX
run: node ./scripts/mdx/compile-mdx.mjs --json --file ${{needs.changes.outputs.CONTENT}}
env:
API_URL: ${{ secrets.API_URL }}
POST_API_KEY: ${{ secrets.POST_API_KEY }}
- name: 🚀 Update content sha
run: cd ./scripts/mdx && node ./update-content-sha.js
env:
COMMIT_SHA: ${{ github.sha }}
API_URL: ${{ secrets.API_URL }}
POST_API_KEY: ${{ secrets.POST_API_KEY }}