-
Notifications
You must be signed in to change notification settings - Fork 4
100 lines (86 loc) · 3.11 KB
/
deploy.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
name: Build and deploy
on:
push:
paths:
- "src/**/*"
- "_config.ts"
- "CNAME"
- "deps.ts"
- ".rebuild" # same ^^
- ".github/workflows/deploy.yml"
env:
DENO_VERSION: v1.39.1
BUILD_ARTIFACT: johan.im-build
BUILD_FOLDER: build
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Build site
run: deno task build --quiet
env:
NODE_ENV: production
ENV: production
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUILD_ARTIFACT }}
path: ${{ env.BUILD_FOLDER }}
retention-days: 1
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download build
uses: actions/download-artifact@v4
with:
name: ${{ env.BUILD_ARTIFACT }}
path: ${{ env.BUILD_FOLDER }}
- name: Deploy to GitHub Pages
if: github.ref_name == 'main'
uses: JamesIves/github-pages-deploy-action@v4
with:
# The branch the action should deploy to.
branch: gh-pages
# The folder the action should deploy.
folder: ${{ env.BUILD_FOLDER }}
- name: Purge Cloudflare cache
if: github.ref_name == 'main'
uses: jakejarvis/cloudflare-purge-action@master
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
maybe-micro-mastodon:
name: Maybe send latest micro post to Mastodon
needs: deploy # can't send post with permalink until site is deployed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
# TODO Wait with posting until site is up?
- name: Post to Mastodon
run: deno run --allow-net --allow-read --allow-write --allow-env script/mastodon.ts
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
- name: Commit and push posted notes
run: |-
git config user.name "Automated"
git config user.email "[email protected]"
git add .mastodon-notes
timestamp=$(date -u)
git commit -m "Latest post to Mastodon: ${timestamp} [skip-ci]" || exit 0
git push