Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Call add-commit-comment script via --notify option of create:env. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson authored Jan 11, 2017
1 parent 7b22566 commit 7f15cf3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ machine:
TERMINUS_ENV_LABEL: CI-$CIRCLE_BUILD_NUM
MULTIDEV_DELETE_PATTERN: ^ci-
PR_DELETE_PATTERN: ^pr-
NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'
PATH: $PATH:~/.composer/vendor/bin:~/.config/composer/vendor/bin:tests/scripts

dependencies:
Expand Down Expand Up @@ -46,8 +47,7 @@ dependencies:
- terminus build-env:delete -n "$TERMINUS_SITE" "$MULTIDEV_DELETE_PATTERN" --keep=2 --delete-branch --yes
- composer -n build-assets
- terminus env:wake -n "$TERMINUS_SITE.dev"
- terminus build-env:create -n "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --label="$TERMINUS_ENV_LABEL" --yes
- scripts/github/add-commit-comment
- terminus build-env:create -n "$TERMINUS_SITE.dev" "$TERMINUS_ENV" --label="$TERMINUS_ENV_LABEL" --yes --notify="$NOTIFY"
test:
override:
- run-behat
Expand Down
27 changes: 15 additions & 12 deletions scripts/github/add-commit-comment
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#!/bin/bash

project="$1"
sha="$2"
comment="$3"
site_url="$4"

token="$(composer config --global github-oauth.github.com)"

# Exit immediately on errors
set -e

# Support for multiple CI platforms
CI_BUILD_REF=${CI_BUILD_REF:-$CIRCLE_SHA1}
if [ -n "$site_url" ] ; then
visit_site="[![Visit Site](https://raw.githubusercontent.com/pantheon-systems/ci-drops-8/0.1.0/data/img/visit-site-36.png)]($site_url)"
fi

SITE_ID=$(terminus site:info $TERMINUS_SITE --field=id)
DASHBOARD="https://dashboard.pantheon.io/sites/$SITE_ID#$TERMINUS_ENV"
comment="Created multidev environment [$TERMINUS_SITE#$TERMINUS_ENV]($DASHBOARD)."
visit_site="[![Visit Site](https://raw.githubusercontent.com/pantheon-systems/ci-drops-8/0.1.0/data/img/visit-site-36.png)](https://$TERMINUS_ENV-$TERMINUS_SITE.pantheonsite.io/)"
if [ -n "$token" ] ; then
curl -d '{ "body": "'"$comment\\n\\n$visit_site"'" }' -X POST https://api.github.com/repos/$project/commits/$sha/comments?access_token=$token

if [ -n "$GITHUB_TOKEN" ] ; then
curl -d '{ "body": "'"$comment\\n\\n$visit_site"'" }' -X POST https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/commits/$CIRCLE_SHA1/comments?access_token=$GITHUB_TOKEN
echo $comment
echo
echo $visit_site
fi

echo $comment
echo
echo $visit_site

3 comments on commit 7f15cf3

@pantheon-upstream
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created multidev environment ci-example-d8-composer#ci-286.

Visit Site

@pantheon-upstream
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created multidev environment ci-example-d8-composer#ci-288.

Visit Site

@pantheon-upstream
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created multidev environment ci-example-d8-composer#ci-289.

Visit Site

Please sign in to comment.