Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #92

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
502f535
fix: test file
vinmassaro Jan 31, 2024
273953a
Update release_pr.yml
vinmassaro Jan 31, 2024
983ad4c
Update release_pr.yml
vinmassaro Jan 31, 2024
f15afe2
Update release_pr.yml
vinmassaro Jan 31, 2024
30a6178
Update release_pr.yml
vinmassaro Jan 31, 2024
bce7ae7
Update release_pr.yml
vinmassaro Jan 31, 2024
627e14a
Update release_pr.yml
vinmassaro Jan 31, 2024
2f19646
Update release_pr.yml
vinmassaro Feb 1, 2024
480a027
Update create_release_pull_request
vinmassaro Feb 1, 2024
d54ffa1
Update release_pr.yml
vinmassaro Feb 1, 2024
36ec49e
Update release_pr.yml
vinmassaro Feb 1, 2024
058b20e
Update release_pr.yml
vinmassaro Feb 1, 2024
8666c33
Update release_pr.yml
vinmassaro Feb 1, 2024
23695ec
Update release_pr.yml
vinmassaro Feb 1, 2024
553bb09
Update create_release_pull_request
vinmassaro Feb 1, 2024
c3f7a4d
Update create_release_pull_request
vinmassaro Feb 2, 2024
7ab1098
Update release_pr.yml
vinmassaro Feb 2, 2024
25153ed
Update release_pr.yml
vinmassaro Feb 2, 2024
62ba685
Update release_pr.yml
vinmassaro Feb 2, 2024
c2f74c7
Update release_pr.yml
vinmassaro Feb 2, 2024
ab1fd1f
Update release_pr.yml
vinmassaro Feb 5, 2024
f7dd4ea
Update release_pr.yml
vinmassaro Feb 5, 2024
ceae86a
test
vinmassaro Feb 5, 2024
fcb4cec
Update release_pr.yml
vinmassaro Feb 5, 2024
0f9ed96
debug contexts
vinmassaro Feb 5, 2024
ea48671
Update release_pr.yml
vinmassaro Feb 5, 2024
2c0de42
Update create_release_pull_request
vinmassaro Feb 5, 2024
38cd0a3
Update release_pr.yml
vinmassaro Feb 5, 2024
b6fa57b
Create deploy_release_sites
vinmassaro Feb 5, 2024
4619c2f
Update release_pr.yml
vinmassaro Feb 5, 2024
38bfc7a
Update release_pr.yml
vinmassaro Feb 6, 2024
2ca5ea6
Update release_pr.yml
vinmassaro Feb 6, 2024
7c47da7
Update create_release_pull_request
vinmassaro Feb 6, 2024
986db17
Update release_pr.yml
vinmassaro Feb 6, 2024
5cc3301
Update release_pr.yml
vinmassaro Feb 6, 2024
96458a0
Update release_pr.yml
vinmassaro Feb 6, 2024
f7a501b
Delete test.txt
vinmassaro Feb 6, 2024
0f95899
Update release_pr.yml
vinmassaro Feb 6, 2024
765c6e4
Update release_pr.yml
vinmassaro Feb 6, 2024
5732fe6
Update create_release_pull_request
vinmassaro Feb 6, 2024
f8ecdb1
Update release_pr.yml
vinmassaro Feb 6, 2024
7b2fd70
Update create_release_pull_request
vinmassaro Feb 6, 2024
30121a1
Update release_pr.yml
vinmassaro Feb 6, 2024
7e0f6b9
Update release_pr.yml
vinmassaro Feb 6, 2024
db08827
Update release_pr.yml
vinmassaro Feb 6, 2024
6aae7bc
Update release_pr.yml
vinmassaro Feb 6, 2024
bb0d718
make executable
vinmassaro Feb 6, 2024
0ebabea
Update deploy_release_sites
vinmassaro Feb 6, 2024
d835ebc
Update release_pr.yml
vinmassaro Feb 6, 2024
d4956e6
Update create_release_pull_request
vinmassaro Feb 6, 2024
175deeb
Update release_pr.yml
vinmassaro Feb 6, 2024
73c6c17
Update deploy_release_sites
vinmassaro Feb 6, 2024
187c8bb
Update release_pr.yml
vinmassaro Feb 6, 2024
f1ff6da
Update release_pr.yml
vinmassaro Feb 6, 2024
7aa358a
Update deploy_release_sites
vinmassaro Feb 6, 2024
9908bf7
Update release_pr.yml
vinmassaro Feb 6, 2024
a7e2341
Update release_pr.yml
vinmassaro Feb 6, 2024
68b46f0
Update deploy_release_sites
vinmassaro Feb 6, 2024
356ebda
Update deploy_release_sites
vinmassaro Feb 6, 2024
d943209
Update deploy_release_sites
vinmassaro Feb 6, 2024
1fe509d
Update deploy_release_sites
vinmassaro Feb 7, 2024
e724de8
Update release_pr.yml
vinmassaro Feb 7, 2024
fc35268
Update deploy_release_sites
vinmassaro Feb 7, 2024
163ce64
Update deploy_release_sites
vinmassaro Feb 7, 2024
28412a2
Update release_pr.yml
vinmassaro Feb 7, 2024
4691a22
Update release_pr.yml
vinmassaro Feb 7, 2024
278ac9d
Update release_pr.yml
vinmassaro Feb 7, 2024
0857a20
add cleanup file
vinmassaro Feb 7, 2024
2657fc2
Update release_pr.yml
vinmassaro Feb 7, 2024
cbbd992
Merge remote-tracking branch 'origin/develop'
invalid-email-address Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .ci/github/clean_up
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash -x

set -eo pipefail

# Install Terminus Build Bools.
terminus self:plugin:install terminus-build-tools-plugin

# Get release sites and convert to an array.
readarray -t sites_array <<< "$(tr -d '\r' <<< "$RELEASE_SITES")"

# Release branch variable does not exist, so create multidevs for the first time.
if [ "$RELEASE_BRANCH" ]; then
# Set release branch.
#gh variable set RELEASE_BRANCH --body "$RELEASE_BRANCH"

# Prepare output file for comment.
echo "Environments ready for review:" >> output.txt
else
echo "test"
# Get release branch if already set.
#release_branch=$(gh api /repos/"$REPO"/actions/variables --jq '.variables.[] | select(.name=="RELEASE_BRANCH") | .value')
fi

push_code() {
git_path=$(terminus connection:info "$site_with_env" --field=git_url)
git remote add "$site_machine_name" "$git_path"
git fetch "$site_machine_name"
git push "$site_machine_name" "$RELEASE_BRANCH:$RELEASE_BRANCH" --force
terminus workflow:wait "$site_machine_name"."$RELEASE_BRANCH" --max=300
}

process_site() {
site_with_env="$1"
site_machine_name="${site_with_env%.*}"

echo -e "\nCreating multidev $site_machine_name.$RELEASE_BRANCH from $site_with_env...\n"

if [ "$site_machine_name" = "yalesites-platform" ]; then
terminus multidev:create "$site_with_env" "$RELEASE_BRANCH" --no-db --no-files
else
terminus multidev:create "$site_with_env" "$RELEASE_BRANCH"
fi

push_code

# Do a fresh install on yalesites-platform site.
if [ "$site_machine_name" = "yalesites-platform" ]; then
echo -e "\nInstalling clean site for $site_machine_name.$RELEASE_BRANCH...\n"
terminus -n env:wake "$site_machine_name"."$RELEASE_BRANCH"
terminus -n drush "$site_machine_name"."$RELEASE_BRANCH" -- si yalesites_profile -y
terminus -n drush "$site_machine_name"."$RELEASE_BRANCH" -- cr
SITE_MACHINE_NAME="$site_machine_name" env="$RELEASE_BRANCH" ./scripts/shared/content-import.sh
fi

terminus -n env:wake "$site_machine_name"."$RELEASE_BRANCH"
echo -e "\nRunning drush deploy...\n"
terminus -n drush "$site_machine_name"."$RELEASE_BRANCH" -- deploy -v -y

# Get site URL and output to file
site_url=$(terminus -n domain:list "$site_machine_name"."$RELEASE_BRANCH" --filter='type=platform' --field=id)
echo "- https://$site_url" >> output.txt
}

# Export functions so that GNU Parallel can access them
export -f push_code
export -f process_site

parallel --jobs 0 --keep-order --line-buffer process_site {} ::: "${sites_array[@]}"

# If we are creating the PR for the first time, post a comment with the created site URLs.
gh issue comment "$PR_NUMBER" --body-file output.txt

# TODO: after PR closed, delete multidevs
# TODO: support new commits, push new code to multidevs
15 changes: 11 additions & 4 deletions .ci/github/create_release_pull_request
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

set -eo pipefail

# If we aren't updating an existing pull request, create one to merge develop into master.
# If we aren't updating an existing pull request, create one to merge the release branch into master.
if [[ -z "$PR_NUMBER" ]]; then
pull_request_response=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: token $ACCESS_TOKEN" \
-X POST -d '{"title": "Release", "head": "develop", "base": "master"}' \
-X POST -d '{"title": "Release", "head": "'"$RELEASE_BRANCH"'", "base": "master"}' \
"https://api.github.com/repos/$REPO/pulls")

message=$(echo "$pull_request_response" | jq -r 'if has("errors") then .errors[].message else null end')
message=$(echo "$pull_request_response" | jq -r 'if has("errors") then .errors[].message else empty end')

# Check if the pull request creation was successful.
if [[ -n "$message" ]]; then
Expand All @@ -23,6 +23,9 @@ if [[ -z "$PR_NUMBER" ]]; then
# Extract the pull request number from the response.
PR_NUMBER=$(echo "$pull_request_response" | jq -r '.number')

# Set PR_NUMBER for Github Actions.
echo PR_NUMBER="$PR_NUMBER" >> "$GITHUB_OUTPUT"

# If there is an existing PR number, get the PR.
else
pull_request_response=$(curl --silent -H "Authorization: token $ACCESS_TOKEN" \
Expand All @@ -31,6 +34,10 @@ else
pr_url=$(echo "$pull_request_response" | jq -r '.html_url')
fi

if [[ -z "$RELEASE_PR_URL" ]]; then
RELEASE_PR_URL="$pr_url"
fi

# Page through the /pulls/#/commits endpoint.
page=1
per_page=100
Expand Down Expand Up @@ -63,7 +70,7 @@ for sha in $commit_shas; do
"https://api.github.com/repos/$REPO/commits/$sha/pulls" \
| jq -r 'if type == "object" and has("message") and length > 0 then null else .[].html_url // empty end')

if [[ -n "$single_pr_url" && "$single_pr_url" != "null" ]]; then
if [[ -n "$single_pr_url" && "$single_pr_url" != "null" && "$single_pr_url" != "$RELEASE_PR_URL" ]]; then
pull_requests+=("$single_pr_url")
elif [[ "$single_pr_url" == "null" ]]; then
:
Expand Down
74 changes: 74 additions & 0 deletions .ci/github/deploy_release_sites
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash -x

set -eo pipefail

# Install Terminus Build Bools.
terminus self:plugin:install terminus-build-tools-plugin

# Get release sites and convert to an array.
readarray -t sites_array <<< "$(tr -d '\r' <<< "$RELEASE_SITES")"

# Release branch variable does not exist, so create multidevs for the first time.
if [ "$RELEASE_BRANCH" ]; then
# Set release branch.
#gh variable set RELEASE_BRANCH --body "$RELEASE_BRANCH"

# Prepare output file for comment.
echo "Environments ready for review:" >> output.txt
else
echo "test"
# Get release branch if already set.
#release_branch=$(gh api /repos/"$REPO"/actions/variables --jq '.variables.[] | select(.name=="RELEASE_BRANCH") | .value')
fi

push_code() {
git_path=$(terminus connection:info "$site_with_env" --field=git_url)
git remote add "$site_machine_name" "$git_path"
git fetch "$site_machine_name"
git push "$site_machine_name" "$RELEASE_BRANCH:$RELEASE_BRANCH" --force
terminus workflow:wait "$site_machine_name"."$RELEASE_BRANCH" --max=300
}

process_site() {
site_with_env="$1"
site_machine_name="${site_with_env%.*}"

echo -e "\nCreating multidev $site_machine_name.$RELEASE_BRANCH from $site_with_env...\n"

if [ "$site_machine_name" = "yalesites-platform" ]; then
terminus multidev:create "$site_with_env" "$RELEASE_BRANCH" --no-db --no-files
else
terminus multidev:create "$site_with_env" "$RELEASE_BRANCH"
fi

push_code

# Do a fresh install on yalesites-platform site.
if [ "$site_machine_name" = "yalesites-platform" ]; then
echo -e "\nInstalling clean site for $site_machine_name.$RELEASE_BRANCH...\n"
terminus -n env:wake "$site_machine_name"."$RELEASE_BRANCH"
terminus -n drush "$site_machine_name"."$RELEASE_BRANCH" -- si yalesites_profile -y
terminus -n drush "$site_machine_name"."$RELEASE_BRANCH" -- cr
SITE_MACHINE_NAME="$site_machine_name" env="$RELEASE_BRANCH" ./scripts/shared/content-import.sh
fi

terminus -n env:wake "$site_machine_name"."$RELEASE_BRANCH"
echo -e "\nRunning drush deploy...\n"
terminus -n drush "$site_machine_name"."$RELEASE_BRANCH" -- deploy -v -y

# Get site URL and output to file
site_url=$(terminus -n domain:list "$site_machine_name"."$RELEASE_BRANCH" --filter='type=platform' --field=id)
echo "- https://$site_url" >> output.txt
}

# Export functions so that GNU Parallel can access them
export -f push_code
export -f process_site

parallel --jobs 0 --keep-order --line-buffer process_site {} ::: "${sites_array[@]}"

# If we are creating the PR for the first time, post a comment with the created site URLs.
gh issue comment "$PR_NUMBER" --body-file output.txt

# TODO: after PR closed, delete multidevs
# TODO: support new commits, push new code to multidevs
Loading
Loading