Build out testing workflow #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
fetch-depth: 0 | |
- 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 |