-
Notifications
You must be signed in to change notification settings - Fork 6
149 lines (129 loc) · 4.5 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# This workflow listens to new pushes to
# the main and staging branches, as well as
# pull requests to those branches.
#
# It then runs all our linters on this content
# and then applies to `automerge` label for any pull
# request created by `box-devrel` with the `allow-automerge`
# label.
name: Lint & Build
on:
push:
branches:
- main
- staging
pull_request:
branches:
- main
- staging
jobs:
# Lint the content and trigger an auto merge on a pull request
lint:
runs-on: ubuntu-latest
timeout-minutes: 3
strategy:
matrix:
node-version: [14.x]
steps:
# Check out the current branch
- name: Check out the repo
uses: actions/checkout@v2
# Set up Node JS
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# Determine the content repo to pull from
- uses: haya14busa/action-cond@v1
id: content_repo
with:
cond: ${{ github.ref == 'refs/heads/staging' }}
if_true: "https://github.com/box/developer.box.com.git#en-staging"
if_false: "https://github.com/box/developer.box.com.git#en"
# Perform a lint of the content
- name: Lint the content
# Pull in the guides from the `en` branch for link validation
env:
CONTENT_REPO: ${{ steps.content_repo.outputs.value }}
# Install the dependencies and run the linter
run: |
yarn install
yarn lint
# If this is a PR by `box-devrel`, then apply the
# `automerge` label after linting passes.
- name: Apply the automerge label if needed
uses: christianvuerings/add-labels@v1
if:
${{ github.event_name == 'pull_request' && github.actor ==
'box-devrel' }}
with:
labels: automerge
# Use a personal access token from box-devrel
# This allows for other workflows to be triggered by this label being added
env:
GITHUB_TOKEN: ${{ secrets.DISPATCH_ACCESS_TOKEN }}
# Split the payload ref so we can parse the branch name
- uses: jungwinter/split@v1
id: split
with:
msg: ${{ github.ref }}
seperator: "/"
# Finally, send a slack notification to the team to warn them of the new changes.
- name: Send Slack notification
uses: Ilshidur/[email protected]
if: ${{ github.ref == 'refs/heads/master' }}
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: GitHub Actions
SLACK_AVATAR: "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4"
with:
args: "Developer Changelog: linting and testing"
# Deploy any new changes from the `main` / `staging` branches to the
# `en` and `en-staging` branches.
deploy:
runs-on: ubuntu-latest
timeout-minutes: 3
# Being extra explicit, we only want this to run on the main and staging branches.
if: (github.ref == 'refs/heads/main') || github.ref == 'refs/heads/staging'
strategy:
matrix:
node-version: [14.x]
# Requires the lint job to pass first
needs:
- lint
steps:
# Check out the current branch
- name: Check out the repo
uses: actions/checkout@v2
# Compile the content to the build folder
- name: Compile the content
run: |
yarn install
yarn build
# Determine the name of the branch to deploy to
- uses: haya14busa/action-cond@v1
id: branch
with:
cond: ${{ github.ref == 'refs/heads/main' }}
if_true: "en"
if_false: "en-staging"
# Push the new build to the correct branch
- name: Push compiled content
uses: s0/[email protected]
env:
REPO: self
BRANCH: ${{ steps.branch.outputs.value }}
FOLDER: compiled
GITHUB_TOKEN: ${{ secrets.DISPATCH_ACCESS_TOKEN }}
# Send a slack notification to notify our team that a new release has been
# received.
- name: Send Slack notification
uses: Ilshidur/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: GitHub Actions
SLACK_AVATAR: "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4"
with:
args:
"Developer Changelog: Pushed latest markdown to `${{
steps.branch.outputs.value }}` branch :rocket:"