-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
71 lines (61 loc) · 2.71 KB
/
action.yaml
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
name: Trigger Source Operations
description: 'Runs the source operations toolkit to trigger a source operation update'
inputs:
github_token: # owner of the repo
description: 'Github personal access token with access rights to the target repository so we can work with the github api. **REQUIRED**.'
required: true
platformsh_token:
description: 'Platform.sh API Token. Needed to trigger the source operation.'
required: true
update_branch_name:
description: 'Name of the branch where you want to run the updates. Defaults to "update"'
required: false
default: ''
#env:
# PLATFORMSH_CLI_TOKEN: ${{ secrets.TEMPLATES_CLI_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.TEMPLATES_GITHUB_TOKEN }}
# GH_TOKEN:
# We need to
# 1. set up python since the source-op toolkit is written in Python
# 2. Set up the platform.sh cli tool. Yes, we're still using the php install method
# 3. Set up the environmental variables
runs:
using: "composite"
steps:
- name: 'Setup Python'
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: 'Setup Environmental Variables'
shell: bash
run: |
echo "PLATFORMSH_CLI_TOKEN=${{inputs.platformsh_token}}" >> $GITHUB_ENV
# in a workflow you need GITHUB_TOKEN, but I think you have to have GH_TOKEN in an action?
echo "GH_TOKEN=${{inputs.github_token}}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{inputs.github_token}}" >> $GITHUB_ENV
- name: "Install PSH CLI tool"
shell: bash
run: |
curl -fsS https://platform.sh/cli/installer | php
# for some reason, sourcing our .bashrc file does not successfully prepend our path to PATH
# export PATH="${HOME}/.platformsh/bin:${PATH}"
echo "PATH=${HOME}/.platformsh/bin:${PATH}" >> $GITHUB_ENV
- name: 'Checkout the repo'
uses: actions/checkout@v3
- name: 'Get project ID'
uses: platformsh/gha-retrieve-projectid@main
with:
github_token: ${{ inputs.github_token }}
- name: 'Run SourceOp Tools'
shell: bash
run: |
if [[ "${PATH}" != *".platformsh"* ]]; then
echo "psh installer not in PATH"
export PATH="${HOME}/.platformsh/bin:${PATH}"
fi
if [[ '' != "${{ inputs.update_branch_name }}" ]]; then
echo "Alternate update branch name requested. Changing..."
export PSH_SOP_UPDATE_BRANCH="${{ inputs.update_branch_name }}"
fi
printf "Beginning Source Operations toolkit install...\n"
curl -fsS https://raw.githubusercontent.com/platformsh/source-operations/main/setup.sh | { bash /dev/fd/3 trigger-sopupdate; } 3<&0