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 v1.0.1 #108

Closed
wants to merge 98 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 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
116f564
Update clean_up
vinmassaro Feb 7, 2024
1d8dd33
Update release_pr.yml
vinmassaro Feb 7, 2024
9cb85c4
Update release_pr.yml
vinmassaro Feb 8, 2024
a313a8f
Update release_pr.yml
vinmassaro Feb 8, 2024
62e0635
Rename clean_up to clean_up_multidevs
vinmassaro Feb 14, 2024
c0411e4
Update release_pr.yml
vinmassaro Feb 14, 2024
4c1f7ef
Update deploy_release_sites
vinmassaro Feb 14, 2024
dc080ce
Update clean_up_multidevs
vinmassaro Feb 14, 2024
4837535
Update deploy_release_sites
vinmassaro Feb 14, 2024
0839843
Update release_pr.yml
vinmassaro Feb 15, 2024
367b0e6
Update deploy_release_sites
vinmassaro Feb 15, 2024
c22587c
Update release_pr.yml
vinmassaro Feb 15, 2024
02d8cc1
fix(YALB-1714): pin gin_lb module to ensure patch applies (#561)
nJim Feb 12, 2024
8de605c
Update deploy_release_sites
vinmassaro Feb 15, 2024
8045d0c
Update release_pr.yml
vinmassaro Feb 19, 2024
125d66d
Update release_pr.yml
vinmassaro Feb 19, 2024
5f86597
Update create_release_pull_request
vinmassaro Feb 19, 2024
ba109e0
Update release_pr.yml
vinmassaro Feb 19, 2024
cb81021
Update release_pr.yml
vinmassaro Feb 20, 2024
348ed73
Update release_pr.yml
vinmassaro Feb 20, 2024
21d7de5
Update deploy_release_sites
vinmassaro Feb 20, 2024
4c29a7c
Update deploy_release_sites
vinmassaro Feb 20, 2024
06ab863
Create test_var.yml
vinmassaro Feb 21, 2024
e9ad621
Update test_var.yml
vinmassaro Feb 21, 2024
0326d96
Update release_pr.yml
vinmassaro Feb 21, 2024
3f8d94c
Update release_pr.yml
vinmassaro Feb 21, 2024
249c5d7
Update release_pr.yml
vinmassaro Feb 21, 2024
ee6f8ec
Update release_pr.yml
vinmassaro Feb 21, 2024
6ed6b1f
Merge remote-tracking branch 'origin/develop'
invalid-email-address Feb 21, 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
18 changes: 18 additions & 0 deletions .ci/github/clean_up_multidevs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -x

clean_up_multidevs() {
site_with_env="$1"
site_machine_name="${site_with_env%.*}"
terminus multidev:delete "$site_machine_name"."$RELEASE_BRANCH" --delete-branch -y
}

export -f clean_up_multidevs

# Get sites into array.
readarray -t release_sites <<< "$(tr -d '\r' <<< "$RELEASE_SITES")"

# Run cleanup with parallel.
parallel --jobs 0 --keep-order --line-buffer clean_up_multidevs ::: "${release_sites[@]}"

# Reset tracking variable for release site deployment.
gh variable set RELEASE_SITES_DEPLOYED --body "0"
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 '"$NEXT_VERSION"'", "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
75 changes: 75 additions & 0 deletions .ci/github/deploy_release_sites
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash -x

set -eo pipefail

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=420
}

drush_deploy() {
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
}

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

env_status=$(terminus env:info "$site_machine_name"."$RELEASE_BRANCH" --field=initialized 2>/dev/null)

# If multidev does not exist, create it, otherwise deploy code updates.
if [ "$env_status" != 1 ]; then
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" --delay=20
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

drush_deploy

# 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
else
push_code
drush_deploy
fi
}

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

# 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")"

# Process sites with parallel.
parallel --jobs 0 --keep-order --line-buffer process_site {} ::: "${sites_array[@]}"

echo "Environments ready for review:" | cat - output.txt > temp && mv temp output.txt

# If release sites don't exist, post a comment with URLs and set tracking variable to 1.
if [ "$RELEASE_SITES_DEPLOYED" == 0 ]; then
gh issue comment "$PR_NUMBER" --body-file output.txt
gh variable set RELEASE_SITES_DEPLOYED --body "1"
fi
196 changes: 172 additions & 24 deletions .github/workflows/release_pr.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,75 @@
name: Create/update release pull request
name: Release pull request
on:
pull_request:
types:
- synchronize
- closed
branches:
- master
workflow_dispatch:
env:
YALESITES_BUILD_TOKEN: ${{ secrets.YALESITES_BUILD_TOKEN }}
GH_TOKEN: ${{ secrets.YALESITES_BUILD_TOKEN }}
ACCESS_TOKEN: ${{ secrets.YALESITES_BUILD_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.number }}
RELEASE_PR_URL: ${{ github.event.pull_request._links.html.href }}
RELEASE_SITES: ${{ vars.RELEASE_SITES }}
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Determine Terminus version
shell: bash
run: |
TERMINUS_RELEASE=$(
curl --silent \
--header 'authorization: Bearer ${{ github.token }}' \
"https://api.github.com/repos/pantheon-systems/terminus/releases/latest" \
| perl -nle'print $& while m#"tag_name": "\K[^"]*#g'
)
echo "TERMINUS_RELEASE=$TERMINUS_RELEASE" >> $GITHUB_ENV

- name: Install Terminus
shell: bash
run: |
mkdir ~/terminus && cd ~/terminus
echo "Installing Terminus v$TERMINUS_RELEASE"
curl -L https://github.com/pantheon-systems/terminus/releases/download/$TERMINUS_RELEASE/terminus.phar -o /usr/local/bin/terminus
chmod +x /usr/local/bin/terminus

- name: Authenticate to Terminus
env:
TERMINUS_TOKEN: ${{ secrets.TERMINUS_TOKEN }}
run: |
terminus auth:login --machine-token="${TERMINUS_TOKEN}"

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary
config: ${{ secrets.SSH_CONFIG }}

- name: Cache terminus
uses: actions/cache@v4
id: terminus-cache
with:
path: |
/usr/local/bin/terminus
~/.terminus
~/.ssh
key: ${{ runner.os }}-terminus-cache-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-terminus-cache-

get_next_release_version:
runs-on: ubuntu-latest
needs: [setup]
if: ${{ github.event.action != 'synchronize' && github.event.action != 'closed' }}
outputs:
NEXT_VERSION: ${{ steps.get_release_number.outputs.next_version }}
RELEASE_BRANCH: ${{ steps.get_release_number.outputs.release_branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -29,31 +87,121 @@ jobs:
git config user.name github-actions
git config user.email [email protected]

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- name: Get next release number
id: get_release_number
run: |
git branch develop origin/develop
git merge develop --no-edit -X theirs
git status
npm install --force
npx --no-install semantic-release --no-ci --dry-run --branches master
next_version=$(npx --no-install semantic-release --no-ci --dry-run --branches master 2>/dev/null | sed -nE 's/.*the next release version is ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p')
echo release_branch="rel-${next_version//.}" >> "$GITHUB_ENV"
if [[ "$PR_NUMBER" ]]; then
release_branch=$(gh pr view "$PR_NUMBER" --json headRefName --jq '.[]')
else
git merge origin/develop --no-edit -X theirs
npm install --force
unset GITHUB_ACTIONS
unset GITHUB_EVENT_NAME
semantic_release=$(npx --no-install semantic-release --no-ci --dry-run 2>/dev/null)
next_version=$(echo "$semantic_release" | sed -nE 's/.*The next release version is ([0-9]+\.[0-9]+\.[0-9]+).*/v\1/p')

if [ -z "$next_version" ]; then
exit 1
else
release_branch="${next_version//.}"
fi
fi

# Set outputs for next steps when running from workflow_dispatch.
echo next_version="$next_version" >> "$GITHUB_OUTPUT"
echo release_branch="$release_branch" >> "$GITHUB_OUTPUT"

# Set release branch as a variable for access.
gh variable set RELEASE_BRANCH --body "$release_branch"

- name: Create release branch
if: ${{ github.event.number == '' }}
env:
RELEASE_BRANCH: ${{ steps.get_release_number.outputs.release_branch }}
run: |
echo "The release branch is: $RELEASE_BRANCH"
git checkout -b "$RELEASE_BRANCH"
git push origin "$RELEASE_BRANCH"

create_pull_request:
needs: [setup, get_next_release_version]
if: ${{ always() && github.event.action != 'closed' }}
outputs:
PR_NUMBER: ${{ steps.create_pull_request.outputs.PR_NUMBER }}
env:
RELEASE_BRANCH: ${{ needs.get_next_release_version.outputs.RELEASE_BRANCH || vars.RELEASE_BRANCH }}
NEXT_VERSION: ${{ needs.get_next_release_version.outputs.NEXT_VERSION }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create pull request
id: create_pull_request
run: ./.ci/github/create_release_pull_request

release_sites:
needs: [setup, get_next_release_version, create_pull_request]
runs-on: ubuntu-latest
if: ${{ always() && github.event.action != 'closed' }}
env:
BRANCH_DEBUG: ${{ needs.get_next_release_version.outputs.RELEASE_BRANCH }}
RELEASE_BRANCH: ${{ needs.get_next_release_version.outputs.RELEASE_BRANCH || vars.RELEASE_BRANCH }}
PR_NUMBER: ${{ needs.create_pull_request.outputs.PR_NUMBER }}
RELEASE_SITES_DEPLOYED: ${{ vars.RELEASE_SITES_DEPLOYED }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_BRANCH }}
fetch-depth: 0

- name: Git setup
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
git checkout -b "$release_branch"
git push origin "$release_branch"

# create_pull_request:
# if: github.head_ref == 'develop' ||
# github.event_name == 'workflow_dispatch'
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Create pull request
# run: ./.ci/github/create_release_pull_request
git config user.name github-actions
git config user.email [email protected]

- name: Restore cache
uses: actions/cache@v4
id: terminus-cache
with:
path: |
/usr/local/bin/terminus
~/.terminus
~/.ssh
key: ${{ runner.os }}-terminus-cache-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-terminus-cache-

- name: Deploy to environments
run: ./.ci/github/deploy_release_sites

clean_up_multidevs:
if: ${{ github.event.action == 'closed' }}
needs: [setup]
runs-on: ubuntu-latest
env:
RELEASE_BRANCH: ${{ vars.RELEASE_BRANCH }}
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Restore cache
uses: actions/cache@v4
id: terminus-cache
with:
path: |
/usr/local/bin/terminus
~/.terminus
~/.ssh
key: ${{ runner.os }}-terminus-cache-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-terminus-cache-

- name: Clean up
env:
GITHUB_TOKEN: ${{ github.token }}
run: ./.ci/github/clean_up_multidevs
Loading