-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
113 lines (97 loc) · 3.32 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
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
name: Cloudflare Pages Action
description: Deploy your project to Cloudflare Pages with automatic project creation and setup custom domain (with support multiple domain)
author: Ade Hery Shopyan
branding:
icon: 'upload-cloud'
color: 'blue'
inputs:
api-token:
required: true
description: "Set api token"
type: string
account-id:
required: true
description: "Set account id"
type: string
branch:
required: true
description: "Set branch"
type: string
production-branch:
required: true
description: "Set production branch"
type: string
build-directory:
required: true
description: "Set build directory"
type: string
package-manager:
required: true
description: "Set package manager"
type: string
project-name:
required: true
description: "Set project name"
type: string
custom-domains:
required: false
description: "Set custom domains"
default: ""
type: string
working-directory:
required: false
description: "Set working directory"
default: "."
type: string
outputs:
deployment-url:
description: "Define deployment url"
value: ${{ steps.url.outputs.deployment-url }}
pages-url:
description: "Define pages url"
value: ${{ steps.url.outputs.pages-url }}
runs:
using: composite
steps:
- name: Deploy
id: deploy
uses: cloudflare/wrangler-action@v3
with:
workingDirectory: ${{ inputs.working-directory }}
apiToken: ${{ inputs.api-token }}
accountId: ${{ inputs.account-id }}
preCommands: wrangler pages project create ${{ inputs.project-name }} --production-branch=${{ inputs.production-branch }} || true
command: pages deploy ${{ inputs.build-directory }} --project-name=${{ inputs.project-name }} --branch=${{ inputs.branch }} --commit-dirty=true
packageManager: ${{ inputs.package-manager }}
- name: Setup Custom Domains
if: "${{ inputs.custom-domains != '' }}"
uses: kitabisa/cloudflare-pages-action/tools/setup-custom-domains@v2
with:
api-token: ${{ inputs.api-token }}
account-id: ${{ inputs.account-id }}
branch: ${{ inputs.branch }}
production-branch: ${{ inputs.production-branch }}
project-name: ${{ inputs.project-name }}
custom-domains: ${{ inputs.custom-domains }}
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
- name: Get deployment url
id: url
shell: bash
env:
PAGES_URL: ${{ steps.deploy.outputs.deployment-url }}
run: |
if [ -n "${{ inputs.custom-domains }}" ]; then
CUSTOM_DOMAIN_URL=$(echo "${{ inputs.custom-domains }}" | tr ',' '\n' | xargs -I {} echo "https://{}" | tr '\n' ', ' | sed 's/, $//')
fi
if [ -z "$CUSTOM_DOMAIN_URL" ]; then
echo "pages-url=$PAGES_URL" >> $GITHUB_OUTPUT
echo "deployment-url=$CUSTOM_DOMAIN_URL" >> $GITHUB_OUTPUT
echo "Your deployment has been successful"
echo "and can be accessed at $PAGES_URL"
echo "or you can also access it at $CUSTOM_DOMAIN_URL"
else
echo "pages-url=$PAGES_URL" >> $GITHUB_OUTPUT
echo "deployment-url=$PAGES_URL" >> $GITHUB_OUTPUT
echo "Your deployment has been successful"
echo "and can be accessed at $PAGES_URL"
fi