-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
81 lines (77 loc) · 2.91 KB
/
action.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
name: Create static redbean server
description: "Create a single-file cross-platform server within an executable ZIP, powered by redbean 🦞"
branding:
icon: globe
color: red
inputs:
version:
description: "Redbean executable to download & use"
default: "latest"
executable-name:
description: "Name of the redbean executable"
default: "redbean.com"
input:
description: "Location of static files to include"
default: "dist"
fallback:
description: "Fallback file if asset can't be found. Set to `false` to disable."
default: "index.html"
launch:
description: "On startup launch preferred browser pointing to this path. Set to `false` to disable."
default: "/"
cache:
description: "Cache redbean executable"
default: true
runs:
using: "composite"
steps:
- name: Generate paths
id: paths
shell: bash
run: |
echo "::set-output name=executable::$(pwd)/${{ inputs.executable-name }}"
echo "::set-output name=temp::$(mktemp -d)"
- if: ${{ inputs.cache }}
name: Create static symlink to temp directory to work around actions/cache#815
shell: bash
run: ln -snf ${{ steps.paths.outputs.temp }} /tmp/.action-static-redbean
- if: ${{ inputs.cache }}
id: cache
uses: actions/cache@v3
with:
path: /tmp/.action-static-redbean/redbean.com
key: action-static-redbean-${{ inputs.version }}
- if: ${{ !inputs.cache || steps.cache.outputs.cache-hit != 'true' }}
name: Fetch redbean-${{ inputs.version }}.com
run: curl "https://redbean.dev/redbean-${{ inputs.version }}.com" >"${{ steps.paths.outputs.temp }}/redbean.com"
shell: bash
- run: cp "${{ steps.paths.outputs.temp }}/redbean.com" "${{ steps.paths.outputs.executable }}"
shell: bash
- if: ${{ inputs.fallback != false }}
name: Add code for fallback to "${{ inputs.fallback }}"
shell: bash
working-directory: ${{ steps.paths.outputs.temp }}
run: |
unzip -qq "${{ steps.paths.outputs.executable }}" .init.lua
cat <<EOT >> .init.lua
function OnHttpRequest()
if not RoutePath() then
ServeAsset('${{ inputs.fallback }}')
end
end
EOT
zip -qq "${{ steps.paths.outputs.executable }}" .init.lua
rm .init.lua
- if: ${{ inputs.launch != false }}
name: Add code to point browser to "${{ inputs.launch }}"
shell: bash
working-directory: ${{ steps.paths.outputs.temp }}
run: |
unzip -qq "${{ steps.paths.outputs.executable }}" .init.lua
echo "LaunchBrowser('${{ inputs.launch }}')" >> .init.lua
zip -qq "${{ steps.paths.outputs.executable }}" .init.lua
rm .init.lua
- run: zip -qq -r "${{ steps.paths.outputs.executable }}" ./**
name: Add static files to executable
shell: bash
working-directory: ${{ inputs.input }}