-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathaction.yml
92 lines (89 loc) · 3 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
name: "Pull Request Deploy"
description: "A github action to automate the deployment of pull requests"
branding:
icon: "cloud"
color: "blue"
inputs:
server_host:
description: SSH host of the server
required: true
server_username:
description: SSH username
required: true
server_password:
description: SSH password
required: false
server_port:
description: SSH port
required: false
default: 22
server_private_key:
description: SSH private key
required: false
context:
description: Directory in the repository where the Dockerfile or start command is located
required: false
default: "./"
dockerfile:
description: Path to the Dockerfile (optional)
required: false
default: "./Dockerfile"
exposed_port:
description: Port to expose in the container
required: true
envs:
description: Environment variables to pass to the container (multi-line string)
required: false
host_volume_path:
description: This is the path on the host machine you want to map to the container
required: false
container_volume_path:
description: This is the path on the container you want to map to
required: false
github_token:
description: GitHub token to authenticate API requests
required: true
comment:
description: A boolean value stating if the comments feature should be provided
required: false
default: false
outputs:
preview-url:
description: "Preview URL"
value: ${{ steps.execute-deployment.outputs.preview-url }}
runs:
using: 'composite'
steps:
- name: Docker Build
if: github.event.action != 'closed'
shell: bash
run: |
PR_ID="pr_${{ github.event.repository.id }}_${{ github.event.number }}"
cd "${{ inputs.context }}"
docker build -t $PR_ID -f "${{ inputs.dockerfile }}" .
docker save $PR_ID | gzip > "/tmp/${PR_ID}.tar.gz"
- id: execute-deployment
name: Execute deployment
run: |
cd ${{ github.action_path }} && bash entrypoint.sh
shell: bash
env:
SERVER_HOST: ${{ inputs.server_host }}
SERVER_USERNAME: ${{ inputs.server_username }}
SERVER_PASSWORD: ${{ inputs.server_password }}
SERVER_PORT: ${{ inputs.server_port }}
SERVER_PRIVATE_KEY: ${{ inputs.server_private_key }}
CONTEXT: ${{ inputs.context }}
DOCKERFILE: ${{ inputs.dockerfile }}
EXPOSED_PORT: ${{ inputs.exposed_port }}
ENVS: ${{ inputs.envs }}
COMMENT: ${{ inputs.comment }}
REPO_URL: ${{ github.event.repository.clone_url }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.number }}
PR_ACTION: ${{ github.event.action }}
CONTAINER_VOLUME_PATH: ${{ inputs.container_volume_path }}
HOST_VOLUME_PATH: ${{ inputs.host_volume_path }}
PR_ID: "pr_${{ github.event.repository.id }}_${{ github.event.number }}"
GITHUB_TOKEN: ${{ inputs.github_token }}