Last active
August 2, 2017 02:21
-
-
Save jobbin/381eed3152ff1e937ea34ea507645093 to your computer and use it in GitHub Desktop.
[ChatOps]Opsidianとdroneを使って、SlackからAWSへデプロイしてみた ref: http://qiita.com/jobbin/items/a3376351737c07a7680d
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
# masterブランチに対して、 | |
# GitHubのevnetがdeploymentかつenvironmentがproductionと指定された場合 | |
# ビルドを実行 | |
pipeline: | |
ecr: | |
image: plugins/ecr | |
region: ap-northeast-1 | |
repo: 284****1948.dkr.ecr.ap-northeast-1.amazonaws.com/ecr | |
tags: [ latest,drone-test ] | |
secrets: [ ECR_ACCESS_KEY,ECR_SECRET_KEY ] | |
when: | |
branch: master | |
event: deployment | |
environment: production |
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
import boto3 | |
import json | |
import os | |
import http.client | |
def lambda_handler(event, context): | |
conn = http.client.HTTPSConnection("api.github.com") | |
print(event) | |
args = event["args"].split(" ") | |
repo = args[0] | |
branch = args[1] | |
env = args[2] | |
payload = { | |
"ref": branch, | |
"auto_merge": False, | |
"environment": env, | |
"description": "Deploy to "+ env, | |
"required_contexts": [] | |
} | |
headers = { | |
'authorization': "token " + os.environ['GIT_KEY'], | |
'User-Agent': "Awesome-Octocat-App" | |
} | |
conn.request("POST", "/repos/"+ repo +"/deployments", json.dumps(payload).encode("utf-8"), headers) | |
res = conn.getresponse() | |
data = res.read() | |
print(data.decode("utf-8")) | |
return json.dumps({'message': 'Hello world!'}) |
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
FROM centos:6 | |
RUN set -x && \ | |
yum install -y httpd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment