-
Notifications
You must be signed in to change notification settings - Fork 8
116 lines (100 loc) · 4.33 KB
/
project.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
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
116
name: Upsun Demo CI
on:
pull_request:
branches:
- main
# on:
# pull_request_target:
# branches: [main]
# types: [labeled,opened,reopened,synchronize]
# label:
# types: [created, deleted, edited]
env:
UPSUN_CLI_NO_INTERACTION: 1
UPSUN_CLI_TOKEN: ${{secrets.DEVREL_USER_UPSUN_TOKEN}}
TEST_ORG_NAME: demo-test-org
TEST_PROJECT_TITLE: "Demo Test Run (pr-${{ github.ref_name }})"
TEST_PROJECT_REGION: "ca-1"
TEST_PROJECT_REGION_SUFFIX: "platform.sh"
TEST_PROJECT_DEFAULT_BRANCH: ${{ github.event.pull_request.head.ref }}
TEST_PROJECT_STAGING_ENV: ${{ github.event.pull_request.head.ref }}-staging
TEST_PROJECT_BACKEND_PATH: "api/v1/environment"
jobs:
# deactivate_forked_environment:
# runs-on: ubuntu-latest
# if: >-
# github.event.pull_request.head.repo.id != 686099066 &&
# contains(github.event.pull_request.labels.*.name, 'demo-runthrough')
test:
runs-on: ubuntu-latest
steps:
################################################################################################
# A. Setting up tools and authentication to test project/organization.
- name: "[SETUP] 1. Checkout repo"
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: "[SETUP] 2. Set up Homebrew"
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: "[SETUP] 3. Install Upsun CLI"
run: |
echo "::notice::Installing Upsun CLI via HomeBrew."
brew install platformsh/tap/upsun-cli
- name: "[SETUP] 4. Verify Upsun CLI installation"
run: |
echo "::notice::Verifying CLI is installed correctly."
upsun org:info -h
- name: "[SETUP] 5. Verify Upsun CLI authentication"
run: |
echo "::notice::Verifying CLI is authenticated correctly."
# upsun auth:api-token-login
upsun org:info -o $TEST_ORG_NAME name
- name: "[SETUP] 6. Authenticate Upsun CLI for pushes"
run: |
upsun ssh-cert:load --new -y
touch ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
ssh-keyscan ssh.$TEST_PROJECT_REGION.platform.sh -v >> ~/.ssh/known_hosts
ssh-keyscan git.$TEST_PROJECT_REGION.platform.sh -v >> ~/.ssh/known_hosts
################################################################################################
# B. Setting up test project.
- name: "[PROJECT] 1. Create a project in the test org."
run: |
echo "::notice::Create a project in the test org."
upsun project:create -o $TEST_ORG_NAME \
--title "$TEST_PROJECT_TITLE" \
--region "$TEST_PROJECT_REGION.$TEST_PROJECT_REGION_SUFFIX" \
--default-branch $TEST_PROJECT_DEFAULT_BRANCH \
--no-set-remote \
-y
- name: "[PROJECT] 2. Verify local repo and branch."
run: |
echo "::notice::Verifying local repo."
ls -a
git branch
- name: "[PROJECT] 3. Set remote."
run: |
echo "::notice::Setting remote for the project locally."
TEST_PROJECT_ID=$(upsun project:list -o $TEST_ORG_NAME --title "$TEST_PROJECT_TITLE" --pipe)
upsun project:set-remote $TEST_PROJECT_ID
- name: "[PROJECT] 4. Deploy the demo application to Upsun."
run: |
echo "::notice::First push to project."
# cat ~/.ssh/known_hosts
git checkout $TEST_PROJECT_DEFAULT_BRANCH
git pull origin $TEST_PROJECT_DEFAULT_BRANCH
upsun push -y
################################################################################################
# C. First deploy.
################################################################################################
# D. Add a service.
################################################################################################
# E. Promote revision to production.
################################################################################################
# F. Cleanup.
# - name: "[CLEANUP] 1. Delete project."
# run: |
# echo "::notice::Cleaning up after successful run."
# echo "::notice::Deleting project: ${TEST_PROJECT_ID}"
# upsun project:delete $TEST_PROJECT_ID -y