-
Notifications
You must be signed in to change notification settings - Fork 224
Update deploy-to-pantheon.yml #5681
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
Open
vfalconisumo
wants to merge
1
commit into
SumoLogic:main
Choose a base branch
from
vfalconisumo:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+58
−19
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
name: deploy-to-pantheon | ||
|
||
permissions: | ||
contents: read | ||
|
||
deployments: write | ||
contents: write | ||
pull-requests: read | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- .github/** | ||
|
||
jobs: | ||
build-and-deploy-to-pantheon: | ||
|
@@ -37,9 +41,19 @@ jobs: | |
with: | ||
php-version: "8.2" | ||
- name: Install Terminus | ||
uses: pantheon-systems/terminus-github-actions@v1 | ||
with: | ||
pantheon-machine-token: ${{ secrets.PANTHEON_MACHINE_TOKEN }} | ||
run: | | ||
sudo apt update | ||
sudo apt install -y curl php-common php-cli php-xml php-mbstring php-curl git jq | ||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
php -r "if (hash_file('sha384', 'composer-setup.php') === file_get_contents('https://composer.github.io/installer.sig')) { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }" | ||
php composer-setup.php | ||
php -r "unlink('composer-setup.php');" | ||
mv composer.phar /usr/local/bin/composer | ||
export ASSET_ID="$(curl -sL -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' https://api.github.com/repos/vfalconisumo/sumo-terminus/releases | jq -r '.[0].assets[0].id')" | ||
curl -sL -H "Accept: application/octet-stream" -H "X-GitHub-Api-Version: 2022-11-28" -o terminus "https://api.github.com/repos/vfalconisumo/sumo-terminus/releases/assets/$ASSET_ID" | ||
chmod +x terminus | ||
mv terminus /usr/local/bin/terminus | ||
terminus self:update | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
|
@@ -53,19 +67,44 @@ jobs: | |
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
- name: Build the Docusaurus site | ||
run: yarn build | ||
run: | | ||
yarn build | ||
- name: Pantheon, check environment and deploy helpdocs | ||
run: | | ||
# Check for helpdocs environment in Pantheon, create one if not found | ||
PANTHEON_ENV_LIST="$(terminus env:list "${{ vars.PANTHEON_SITE_ID }}" --format=list | xargs)" | ||
DEV_SITE_EXISTS="$(echo "$PANTHEON_ENV_LIST" | grep "helpdocs" | wc -l | xargs)" | ||
if [ "$DEV_SITE_EXISTS" -eq "0" ]; then | ||
terminus multidev:create --no-interaction --no-ansi ${{ vars.PANTHEON_SITE_ID }}.dev helpdocs | ||
terminus lock:enable ${{ vars.PANTHEON_SITE_ID }}.helpdocs -- "${{ secrets.PANTHEON_AUTH_USER }}" "${{ secrets.PANTHEON_AUTH_PASSWORD }}" | ||
fi | ||
# Put environment in SFTP mode, because we're using rsync to move files up | ||
terminus connection:set ${{ vars.PANTHEON_SITE_ID }}.helpdocs sftp | ||
terminus self:plugin:install terminus-rsync-plugin | ||
mv ./build ./help | ||
terminus rsync ./help ${{ vars.PANTHEON_SITE_ID }}.helpdocs:code | ||
terminus env:commit --message "Production build of helpdocs" --force -- ${{ vars.PANTHEON_SITE_ID }}.helpdocs | ||
git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all | ||
git config --global user.email "${{ secrets.PANTHEON_USER_EMAIL }}" | ||
git config --global user.name "GitHub workflow" | ||
terminus auth:login --machine-token ${{ secrets.PANTHEON_MACHINE_TOKEN }} | ||
terminus local:clone --yes ${{ vars.PANTHEON_SITE_ID }} | ||
rsync --archive ./build/ "$HOME/pantheon-local-copies/${{ vars.PANTHEON_SITE_ID }}/help/" | ||
terminus local:commitAndPush --yes sumo-logic-sandbox | ||
terminus workflow:wait --max=600 ${{ vars.PANTHEON_SITE_ID }}.dev | ||
terminus auth:logout | ||
- name: Get runner IP | ||
if: always() | ||
id: ip | ||
uses: haythem/[email protected] | ||
- name: Set env vars | ||
if: always() | ||
run: | | ||
echo "AWS_REGION=us-east-1" >> $GITHUB_ENV | ||
echo "AWS_SG_NAME=webops-sg-jenkins" >> $GITHUB_ENV | ||
- name: Add runner to AWS security group ingress | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.WEBOPS_AWS_ACCESS_KEY }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEBOPS_AWS_SECRET_KEY }} | ||
AWS_DEFAULT_REGION: ${{ env.AWS_REGION }} | ||
run: aws ec2 authorize-security-group-ingress --group-name ${{ env.AWS_SG_NAME }} --protocol tcp --port ${{ secrets.WEBOPS_JENKINS_PORT || '80' }} --cidr ${{ steps.ip.outputs.ipv4 }}/32 | ||
- name: Trigger Jenkins pipeline | ||
run: | | ||
curl -H 'Content-Type: application/json' \ | ||
-d '{ "TRIGGER_SOURCE": "${{ github.event_name }} on ${{ github.ref_name }} in ${{ github.repository }}" }' \ | ||
-X POST \ | ||
${{ secrets.WEBOPS_JENKINS_HOST }}:${{ secrets.WEBOPS_JENKINS_PORT || '80' }}/generic-webhook-trigger/invoke?token=${{ secrets.WEBOPS_WEBHOOK_TOKEN }} | ||
- name: Remove runner from AWS security group ingress | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.WEBOPS_AWS_ACCESS_KEY }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEBOPS_AWS_SECRET_KEY }} | ||
AWS_DEFAULT_REGION: ${{ env.AWS_REGION }} | ||
if: always() | ||
run: aws ec2 revoke-security-group-ingress --group-name ${{ env.AWS_SG_NAME }} --protocol tcp --port ${{ secrets.WEBOPS_JENKINS_PORT || '80' }} --cidr ${{ steps.ip.outputs.ipv4 }}/32 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have concerns about replacing this with a fork in a personal repository.
Why is it necessary?
Can it be avoided?
What will be the ongoing maintenance burden?
If these questions are already documented, please link the document in the PR.
If a fork cannot be avoided, it should be done under the SumoLogic org.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fork from my personal Sumo account is necessary because the command we are using,
local:commitAndPush
, successfully commits and pushes the changes to Pantheon, but that command throws a type error in the upstream because the function expects to return a string but in reality returns a void. That error causes the workflow to show as failing even though it is successful.The maintenance burden falls on my team, and our plan is to use this fork until we can get Pantheon to merge a fix for it upstream.
I am happy to transfer it to an org, but my team's repos live in sanyaku not SumoLogic, so I'm unclear on which org is correct here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Upstream does look buggy for that function. Do we have an issue filed with them?
Sanyaku is an org that is holding private repositories. Since this is intended to be public, let's fork it in the SumoLogic org, which is meant for public repositories, and add a comment to its readme about why we forked, with a link to the upstream issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, opening the PR with them after we complete this migration.
Should I ask IT for the repo in the sumologic org, or does a different team handle its admin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, IT is probably the best way to go about adding a repo to the SumoLogic org. Thanks!