-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
114 lines (93 loc) · 3.93 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
name: 'Platform.sh Deploy status'
description: 'Detect if a platform.sh site has deployed successfully'
branding:
icon: 'clock'
color: 'purple'
inputs:
PLATFORMSH_KEY:
description: "API key for connecting to Platform.sh"
required: true
type: string
PLATFORMSH_ID:
description: "ID for the Platform.sh project."
required: true
type: string
ENVIRONMENT_NAME:
description: "Which environment to check against - defaults to pr-NUMBER"
default: "pr-${{ github.event.pull_request.number }}"
required: false
type: string
ACTIVITY_TYPES:
description: "Comma-seperated types of deployments to wait for. Default: push - See types here: https://docs.platform.sh/integrations/activity/reference.html#environment-activity-types"
default: "push"
required: false
type: string
DEPLOY_STATUS_PATH:
description: 'The location of the deploy-status file on the website.'
default: '/sites/default/files/deploy-status'
required: false
type: string
PSH_DETECTION_WAIT:
description: "How long should we maximum wait for PSH to detect the push? If the branch doesnt exist in the PlatformSH GIT Remote, this is how long the action will take. Actually inactive environments get detected instantly. Default: 30 seconds."
default: 30
required: false
type: integer
ALLOW_CANCEL_CRON:
description: "Can we cancel on-going crons, to speed up deployment? default: 0"
default: 0
required: false
type: integer
outputs:
url:
description: "The ready-to-connect URL"
value: ${{ steps.platformsh_url.outputs.url }}
state:
description: "The state of the deployment, parseable by GitHub Deployment Status"
value: ${{ steps.platformsh_deploy_status.outputs.state }}
state_description:
description: "Short description of the state, such as error message."
value: ${{ steps.platformsh_deploy_status.outputs.state_description }}
runs:
using: "composite"
steps:
- uses: reload/action-platformsh-url@main
id: platformsh_url
with:
PLATFORMSH_ID: ${{ inputs.PLATFORMSH_ID }}
PLATFORMSH_KEY: ${{ inputs.PLATFORMSH_KEY }}
ENVIRONMENT_NAME: ${{ inputs.ENVIRONMENT_NAME }}
PSH_DETECTION_WAIT: ${{ inputs.PSH_DETECTION_WAIT }}
ALLOW_CANCEL_CRON: ${{ inputs.ALLOW_CANCEL_CRON }}
ACTIVITY_TYPES: ${{ inputs.ACTIVITY_TYPES }}
- name: Check latest deploy status
id: platformsh_deploy_status
shell: bash
run: |
set +e
URL="${{ steps.platformsh_url.outputs.url }}"
DEPLOY_STATUS_URL="$URL${{ inputs.DEPLOY_STATUS_PATH }}"
echo "Checking $DEPLOY_STATUS_URL .."
CURL_HTTP_STATUS=$(curl -L -s -o /dev/null -w "%{http_code}" $DEPLOY_STATUS_URL)
if [[ "$CURL_HTTP_STATUS" != "200" ]]; then \
STATE_DESCRIPTION="Could not find the deploy-status file at $DEPLOY_STATUS_URL"; \
echo "$STATE_DESCRIPTION"; \
echo "Did you remember to create during the build step in .platform.app.yaml?"; \
echo "More info: https://github.com/reload/action-platformsh-deploy-status#the-deploy-status-file"; \
echo "state=error" >> $GITHUB_OUTPUT; \
echo "state_description=error" >> $GITHUB_OUTPUT; \
exit 2; \
fi
CURL_STATUS=$(curl -L -s $DEPLOY_STATUS_URL)
if [[ "$CURL_STATUS" != "1" ]]; then \
STATE_DESCRIPTION="PlatformSH silently failed to deploy your PR."; \
echo "$STATE_DESCRIPTION"; \
echo ""; \
echo "You can view the deploy log with:"; \
echo "$ platform log deploy -e ${{ inputs.ENVIRONMENT_NAME }} -p ${{ inputs.PLATFORMSH_ID }}"; \
echo "state=failure" >> $GITHUB_OUTPUT; \
exit 2; \
fi
STATE_DESCRIPTION="PlatformSH successfully deployed your PR."
echo "$STATE_DESCRIPTION"
echo "state=success" >> $GITHUB_OUTPUT
echo "state_description=$STATE_DESCRIPTION" >> $GITHUB_OUTPUT