An ASP.NET Web API web service that accepts Web Hooks from Visual Studio Team Services Git source control and synchronizes changes with Amazon S3
When files are committed to Git source control they are automatically copied to (or removed from) Amazon S3 blob storage.
- Copyright 2015: Brian VanSchyndel, bvan.ca
- Deploy the web service with HTTPS security (e.g., in Azure Web Apps)
- Add a user with AmazonS3FullAccess permission and write down the access key ID and secret
-
Go to a user's profile and select the Security tab
-
Add a Personal access token with Code (read) permission and write down the access token
-
Select a Git project and go to Settings
-
Under the Service Hooks tab add a Web Hooks service
-
Select the "Code pushed" trigger and add any filters
-
Click Next
-
Enter the web service URL
-
Add the following headers, substitute appropriate values and credentials:
Sync-Root:/
Sync-SourceConnectionString:BaseUrl=https://<<user>>.visualstudio.com/DefaultCollection/;UserName=<<VSO username>>;AccessToken=<<VSO access token>>
Sync-DestConnectionString:BucketName=<<S3 bucket name>>;RegionSystemName=<<us-east-1>>;AccessKeyId=<<AWS access key ID>>;SecretAccessKey=<<AWS secret key>>
-
Set "Messages to send" and "Detailed messages to send" to None
-
Click Finish
This header indicates the source control folder to sync.
For example, setting Sync-Root:/wwwroot/
with the following source will sync only the files in /wwwroot/
.
From Git:
/Readme.txt
/wwwroot/index.html
/wwwroot/images/logo.jpg
To AWS S3:
index.html
images/logo.jpg
This connection string property indicates the region of the AWS S3 bucket.
The system name can be found in the endpoint address.
For example, with Endpoint: bvan-test.s3-website-us-east-1.amazonaws.com, the region system name is us-east-1
.