generated from itw-creative-works/ultimate-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (109 loc) · 3.65 KB
/
build.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
name: Compile and Build Site
on:
workflow_dispatch:
push:
branches:
- master
- main
- template
schedule:
- cron: '30 1 1 * *' # every 1st of the month at 1:30 am UTC
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
# GH_TOKEN: ${{ secrets.GH_TOKEN }}
BACKEND_MANAGER_KEY: ${{ secrets.BACKEND_MANAGER_KEY }}
jobs:
build:
# needs: nothing
runs-on: ubuntu-latest
timeout-minutes: 80
steps:
- name: Setup git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "$GITHUB_ACTOR"
- name: Checkout main branch
uses: actions/checkout@v4
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.0'
bundler-cache: false
- name: Install specific bundler version
run: gem install bundler -v 2.4.21
- name: Run bundle install
run: |
bundle install --path vendor/bundle
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 10
- name: Run node install
run: npm install
- name: Log dependency versions
run: |
echo "Unix Version: "
uname -a
echo "Ubuntu Version: "
lsb_release -a
echo "Ruby: $(ruby -v)"
echo "Gem: $(gem -v)"
echo "Bundler: $(bundle -v)"
echo "Node: $(node -v)"
echo "NPM: $(npm -v)"
echo "Gem Versions: "
gem list
echo "NPM Dependeny Versions: "
npm list --depth=0 || echo ""
- name: Run node build
run: npm run build -- --buildLocation='server'
- name: Create build.json
run: |
export TZ=UTC date
timestamp=$(date +%FT%TZ)
temp_build_json=$(cat @output/build/build.json)
echo account: $GITHUB_ACTOR
echo repo: $GITHUB_REPOSITORY
echo timestamp: $timestamp
echo build.json: $temp_build_json
build_log_path="@output/build/build.json"
sed "s/%GHP_TIMESTAMP%/$timestamp/g" $build_log_path > "$build_log_path"-temp && mv "$build_log_path"-temp $build_log_path
sed -n '1h;1!H;${;g;s/GEN>>>.*<<<GEN/<REDACTED FOR LIVE PUBLISH>/g;p;}' .gitignore > .gitignore
# - name: Delete gh-pages branch
# uses: dawidd6/action-delete-branch@v3
# with:
# github_token: ${{ secrets.GH_TOKEN }}
# branches: gh-pages
# soft_fail: true
# - name: Delete gh-pages branch
# continue-on-error: true
# run: |
# curl -L \
# -X DELETE \
# -H "Authorization: token ${{ secrets.GH_TOKEN }}" \
# https://api.github.com/repos/$GITHUB_REPOSITORY/git/refs/heads/gh-pages
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GH_TOKEN }}
publish_dir: ./_site
- name: Purge CloudFlare cache
run: npm run cloudflare:purge
- name: Purge artifacts
uses: kolpav/purge-artifacts-action@v1
with:
token: ${{ secrets.GH_TOKEN }}
expire-in: 30 minutes # Set this to 0 to delete instantly
# - name: Purge artifacts
# uses: c-hive/gha-remove-artifacts@v1
# with:
# age: '5 minutes' # '<number> <unit>', e.g. 5 days, 2 years, 90 seconds, parsed by Moment.js
# # Optional inputs
# # skip-tags: true
# # skip-recent: 5
# - name: Purge artifacts
# uses: geekyeggo/delete-artifact@v5
# with:
# name: github-pages