-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
115 lines (96 loc) · 3.22 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
114
115
name: Feature Preview
description: 🏗️ GitHub Action for deploying feature previews.
inputs:
github-token:
description: "The GitHub token."
required: true
pr-head-ref:
description: "The head ref of the pull request."
required: true
pr-status:
description: "The status of the pull request."
required: true
options:
- opened
- closed
image-path:
description: "The path of the image."
required: true
image-base:
description: "The base of the image."
required: true
cloudflare-email:
description: "The email address for Cloudflare."
required: true
cloudflare-api-key:
description: "The API key for Cloudflare."
required: true
cloudflare-domain:
description: "The domain to deploy the feature preview to."
required: true
cloudflare-target:
description: "The IP address of the server."
required: true
portainer-url:
description: "Portainer URL."
required: true
portainer-username:
description: "Portainer Username."
required: true
portainer-password:
description: "Portainer Password."
required: true
portainer-endpoint-id:
description: "Portainer Endpoint ID."
required: true
env-file:
description: "Env file."
required: true
stack-compose-path:
description: "Path of docker-compose file."
required: true
runs:
using: composite
steps:
- uses: actions/checkout@v4
- name: Get Feature Name
id: get-feature-name
run: echo "name=$(echo ${{ github.event.pull_request.head.ref }} | cut -d '/' -f 2)" >> $GITHUB_OUTPUT
shell: bash
- name: Build
uses: saturdayshdev/build-action@v1.1.0
id: build
if: always() && ${{ inputs.pr-status == 'opened' }}
with:
github-token: ${{ inputs.github-token }}
dockerfile: ${{ inputs.image-path }}/Dockerfile
image: ${{ inputs.image-base }}
tag: feature-${{ steps.get-feature-name.outputs.name }}
- name: Deploy
uses: saturdayshdev/feature-preview-action/action@main
id: deploy
with:
pr-status: ${{ inputs.pr-status }}
feature-name: ${{ steps.get-feature-name.outputs.name }}
cloudflare-email: ${{ inputs.cloudflare-email }}
cloudflare-api-key: ${{ inputs.cloudflare-api-key }}
cloudflare-domain: ${{ inputs.cloudflare-domain }}
cloudflare-target: ${{ inputs.cloudflare-target }}
portainer-url: ${{ inputs.portainer-url }}
portainer-username: ${{ inputs.portainer-username }}
portainer-password: ${{ inputs.portainer-password }}
portainer-endpoint-id: ${{ inputs.portainer-endpoint-id }}
env-file: ${{ inputs.env-file }}
stack-compose-path: ${{ inputs.stack-compose-path }}
- name: Comment
uses: actions/github-script@v7
if: always() && ${{ inputs.pr-status == 'opened' }}
with:
github-token: ${{ inputs.github-token }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚀 Deployed to https://${{ steps.get-feature-name.outputs.name }}.feature.${{ inputs.cloudflare-domain }}'
})