forked from serverless-dns/serverless-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (111 loc) · 3.44 KB
/
deno-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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: 🦕 Deno
on:
push:
branches:
- "main"
paths-ignore:
- ".github/**"
- "!.github/workflows/deno-deploy.yml"
- ".env.example"
- ".eslintrc.cjs"
- ".prettierignore"
- "README.md"
- "wrangler.toml"
- "fly.toml"
- "node.Dockerfile"
- "deno.Dockerfile"
- ".vscode/*"
- ".husky/*"
- ".prettierrc.json"
- "LICENSE"
- "run"
workflow_dispatch:
inputs:
deploy-mode:
description: 'Deploy via action or auto'
required: false
default: 'action'
type: choice
options:
- action
- auto
git-ref:
description: 'Git branch / tag / commit (used for auto deploy-mode)'
required: false
default: 'main'
deployment-type:
description: 'Deploy branch (used for auto deploy-mode)'
required: false
default: 'dev'
type: choice
options:
- dev
- live
env:
DEPLOY_MODE: 'action'
PROJECT_NAME: ${{ secrets.DENO_PROJECT_NAME || 'rdns' }}
BUILD_BRANCH: >
${{ github.event_name == 'workflow_dispatch' &&
github.event.inputs.deployment-type == 'live' &&
'build/deno-deploy/live' || 'build/deno-deploy/dev' }}
IN_FILE: 'src/server-deno.ts'
OUT_FILE: 'rethinkdns.js'
jobs:
deploy:
name: 🌯 Deno Deploy
runs-on: ubuntu-latest
permissions:
# needed for auth with deno.com
id-token: write
# needed to clone repo
contents: read
steps:
- name: 🚚 Fetch code
uses: actions/[email protected]
with:
ref: ${{ github.event.inputs.git-ref || github.ref }}
fetch-depth: 0
- name: 🏝 Setup env
shell: bash
run: |
echo "DEPLOY_MODE=${DM}" >> $GITHUB_ENV
echo "::notice::deploy mode: $DM, project: $PROJECT_NAME"
env:
DM: ${{ github.event.inputs.deploy-mode || env.DEPLOY_MODE }}
- name: 🧰 Checkout deploy-branch
if: ${{ env.DEPLOY_MODE == 'auto' }}
run: |
git fetch --all
git checkout --orphan ${BUILD_BRANCH} || git checkout ${BUILD_BRANCH}
git reset
git merge origin/${BUILD_BRANCH} || :
- name: 🦕 Install Deno @1.29
uses: denoland/setup-deno@main
with:
deno-version: 1.29.3
- name: 📦 Bundle up
if: ${{ env.DEPLOY_MODE == 'action' }}
run: |
echo "::notice::do not forget to set DENO_PROJECT_NAME via github secrets!"
deno task prepare
deno bundle ${IN_FILE} ${OUT_FILE}
shell: bash
# github.com/denoland/deployctl/blob/febd898/action.yml
# step output: www.actionsbyexample.com/outputs.html
- name: 🤸🏼 Deploy to deno.com
id: dd
if: ${{ env.DEPLOY_MODE == 'action' }}
uses: denoland/[email protected]
with:
project: ${{ env.PROJECT_NAME }}
entrypoint: ${{ env.OUT_FILE }}
- name: 🚢 Merge latest code into deploy-branch
if: ${{ env.DEPLOY_MODE == 'auto' }}
run: |
git config --local user.name 'github-actions[bot]'
git config --local user.email 'github-actions[bot]@users.noreply.github.com'
git add ${OUT_FILE}
git commit -m "Update bundle for ${GITHUB_SHA}" && \
echo "::notice::Pushing to ${BUILD_BRANCH}" || \
echo "::notice::No changes to commit"
git push origin ${BUILD_BRANCH}