Skip to content

Commit 37aa6bf

Browse files
committed
Build: Enable deployment from Azure Pipelines
Fix #593
1 parent 327c70d commit 37aa6bf

11 files changed

+103
-269
lines changed

.gitattributes

-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,3 @@
22
# https://git-scm.com/docs/gitattributes#_end_of_line_conversion
33

44
* text=auto
5-
6-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7-
8-
# Exclude the following files from GitHub's language statistics
9-
# https://github.com/github/linguist#using-gitattributes
10-
11-
.travis/* linguist-vendored

.travis.yml

-65
This file was deleted.

.travis/is-travis.sh

-3
This file was deleted.

.travis/swap.sh

-11
This file was deleted.

.travis/update-docs.sh

-8
This file was deleted.

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# webhint's website
22

33
<!-- markdownlint-disable -->
4-
[![Build Status](https://dev.azure.com/webhint/webhint/_apis/build/status/webhintio.webhint.io?branchName=master)](https://dev.azure.com/webhint/webhint/_build/latest?definitionId=2?branchName=master)
5-
[![Build Status](https://travis-ci.org/webhintio/webhint.io.svg?branch=master)](https://travis-ci.org/webhintio/webhint.io) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwebhintio%2Fwebhint.io.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwebhintio%2Fwebhint.io?ref=badge_shield)
4+
[![Build Status](https://dev.azure.com/webhint/webhint/_apis/build/status/webhintio.webhint.io?branchName=master)](https://dev.azure.com/webhint/webhint/_build/latest?definitionId=2?branchName=master) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwebhintio%2Fwebhint.io.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwebhintio%2Fwebhint.io?ref=badge_shield)
65
<!-- markdownlint-enable -->
76

87
This is the code for [webhint's website](https://webhint.io).

architecture/server.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ The content of the live site is updated each time a change is made in the:
5050
* `/docs` directory and/or to the `CHANGELOG.md` file from the `webhint`
5151
repository
5252

53-
To achieve the latter, `webhint` has the [`trigger-site-update.sh`]
54-
[trigger-update] script that triggers a build on `webhint.io` if the
55-
previous conditions are met.
53+
To achieve the latter, `webhint` gets built everytime a build finishes successfully
54+
in the `hint` repository.
5655

5756
The search on the website uses [Algolia][algolia]. The search index is
5857
updated each time there is a deployment.
@@ -61,14 +60,14 @@ updated each time there is a deployment.
6160

6261
The deployment process is fully automated:
6362

64-
1. `master` branch build is triggered in [Travis][travis] (e.g. by code
63+
1. `master` branch build is triggered in [Azure Pipelines][ap] (e.g. by code
6564
or documentation change).
66-
1. build passes and executes `.travis/update-site.sh`.
65+
1. build passes and executes `helpers/update-site.sh`.
6766
This script will copy the required files for the deployment and push
6867
them into a local Git on Azure in the staging environment.
6968
1. The staging environment will be tested with `webhint` to make sure
70-
everything is alrigh. If so, the code will get into production via
71-
`.travis/swap.sh`.
69+
everything is alrigh. If so, the code will get into production after
70+
swapping slots in the Azure WebApp.
7271

7372
## Production configuration
7473

@@ -154,6 +153,7 @@ IIS manages the custom error page via the following entries in `web.config`:
154153
```
155154

156155
[algolia]: https://www.algolia.com
156+
[ap]: https://dev.azure.com/webhint/webhint/_build?definitionId=2&_a=summary
157157
[cd]: https://docs.microsoft.com/en-us/azure/app-service/app-service-continuous-deployment
158158
[handlebars]: https://handlebarsjs.com
159159
[hexo]: https://hexo.io
@@ -162,5 +162,4 @@ IIS manages the custom error page via the following entries in `web.config`:
162162
[siteextenstion]: https://github.com/sjkp/letsencrypt-siteextension
163163
[webhint]: https://webhint.io
164164
[webhint-repo]: https://github.com/webhintio/hint
165-
[travis]: https://travis-ci.org/webhint/webhint.io
166165
[trigger-update]: https://github.com/webhintio/hint/blob/0cfb1bb49c847eb4d5ed54691dbb88cb796694bf/.travis/trigger-site-update.sh

azure-pipelines.yml

+49-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,51 @@
1-
pool:
2-
vmImage: 'Ubuntu 16.04'
1+
# Scope the validations to master and PRs to master
2+
trigger:
3+
- master
4+
pr:
5+
- master
36

4-
steps:
5-
- task: NodeTool@0
6-
inputs:
7-
versionSpec: '8.x'
8-
displayName: 'Install Node.js'
7+
# We have one single job with conditional steps for changes in master
8+
jobs:
9+
- job: 'webhintio'
10+
pool:
11+
vmImage: 'Ubuntu 16.04'
12+
steps:
13+
- task: NodeTool@0
14+
inputs:
15+
versionSpec: '10.x'
16+
displayName: 'Install Node.js'
17+
- script: npm ci
18+
displayName: 'Install dependencies'
19+
- script: npm test
20+
displayName: 'Test'
21+
- script: ./helpers/update-site.sh
22+
displayName: 'Deploy'
23+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
24+
env:
25+
GIT_USER_EMAIL: $(GIT_USER_EMAIL)
26+
GIT_USER_NAME: $(GIT_USER_NAME)
27+
GIT_PASSWORD: $(GIT_PASSWORD)
28+
- script: npm run test-staging
29+
displayName: 'Analyze staging with webhint'
30+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
31+
- bash: |
32+
az login --service-principal -u $AZURE_SERVICE_PRINCIPAL -p $AZURE_SERVICE_PRINCIPAL_PASSWORD --tenant $AZURE_TENANT
33+
az webapp deployment slot swap -g sonarwhal -n sonarwhal --slot staging
34+
displayName: 'Swap into production'
35+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
36+
env:
37+
AZURE_SERVICE_PRINCIPAL: $(AZURE_SERVICE_PRINCIPAL)
38+
AZURE_SERVICE_PRINCIPAL_PASSWORD: $(AZURE_SERVICE_PRINCIPAL_PASSWORD)
39+
AZURE_TENANT: $(AZURE_TENANT)
40+
- bash: |
41+
curl https://www.google.com/ping?sitemap=https://webhint.io/sitemap.xml
42+
curl https://www.bing.com/ping?sitemap=https://webhint.io/sitemap.xml
43+
displayName: 'Update sitemaps'
44+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
945
10-
- script: |
11-
npm ci
12-
npm test
13-
displayName: 'npm install and test'
46+
- job: 'Algolia'
47+
pool:
48+
vmImage: 'Ubuntu 16.04'
49+
steps:
50+
- script: npm run ci-docsearch-scraper
51+
condition: eq(variables['Build.Reason'], 'Schedule')

.travis/update-site.sh helpers/update-site.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ update_website() {
3939
&& git config --global user.name "$GIT_USER_NAME" \
4040
&& git init \
4141
&& git add -A \
42-
&& git commit --message "Hey server, this content is for you! [skip ci]" \
42+
&& git commit --message "Hey server, this content is for you! ***NO_CI***" \
4343
&& git push --quiet --force --set-upstream "https://$GIT_USER_NAME:$GIT_PASSWORD@sonarwhal-staging.scm.azurewebsites.net:443/sonarwhal.git" master
4444
}
4545

0 commit comments

Comments
 (0)