forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (131 loc) · 5.74 KB
/
Copy pathdeployExpensifyHelp.yml
File metadata and controls
153 lines (131 loc) · 5.74 KB
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
150
151
152
153
name: Deploy ExpensifyHelp
on:
# Run on any push to main that has changes to the docs directory
push:
branches:
- main
paths:
- 'docs/**'
- '.github/workflows/deployExpensifyHelp.yml'
# Run on any pull request (except PRs against staging or production) that has changes to the docs directory
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]
paths:
- 'docs/**'
- '.github/workflows/deployExpensifyHelp.yml'
# Run on any manual trigger
workflow_dispatch:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
env:
IS_PR_FROM_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }}
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Checkout
uses: useblacksmith/checkout@c9796daa2a4bdebdab5bd16be2c09a70cd4e1121 # v1
with:
fetch-depth: 0
- name: Install pcregrep
run: sudo apt-get install -y pcregrep
- name: Setup NodeJS
uses: ./.github/actions/composite/setupNode
- name: Create docs routes file
run: ./.github/scripts/createDocsRoutes.sh
- name: Check for duplicates and cycles in redirects.csv
run: ./.github/scripts/verifyRedirect.sh
- name: Enforce that a redirect link has been created
run: ./.github/scripts/enforceRedirect.sh
- name: Enforce iframe and Cloudflare CDN usage
run: ./.github/scripts/enforceVideoFormats.sh
- name: Generate allowed URLs whitelist for AI search
run: npx ts-node .github/scripts/generateAllowedUrls.ts
- name: Set up Ruby
# v1.306.0
uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f
with:
bundler-cache: true
working-directory: ./docs
- name: Build Jekyll site
run: bundle exec jekyll build --source ./ --destination ./_site
working-directory: ./docs
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
id: deploy
if: env.IS_PR_FROM_FORK != 'true'
with:
apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy ./docs/_site --project-name=helpdot
- name: Setup Cloudflare CLI
if: env.IS_PR_FROM_FORK != 'true'
run: pip3 install cloudflare==2.19.0
- name: Purge Cloudflare cache
if: env.IS_PR_FROM_FORK != 'true'
run: /home/runner/.local/bin/cli4 --verbose --delete hosts=["help.expensify.com"] /zones/:9ee042e6cfc7fd45e74aa7d2f78d617b/purge_cache
env:
CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }}
- name: Check if only articles are updated
if: ${{ github.event_name == 'pull_request' }}
id: verify_articles_only_updated
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
with:
filters: |
articles:
- 'docs/articles/**'
- 'docs/**/*.csv'
- name: Ensure PR title has [No QA] prefix
if: ${{ github.event_name == 'pull_request' && env.IS_PR_FROM_FORK != 'true' && steps.verify_articles_only_updated.outputs.articles == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
current_title=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json title -q '.title')
if [[ "$current_title" == "[No QA]"* ]]; then
echo "PR title already contains [No QA]; skipping."
exit 0
fi
gh pr edit "$PR_NUMBER" --repo "$REPO" --title "[No QA] $current_title"
- name: Generate ExpensifyHelp preview comment
id: preview_comment
if: ${{ github.event_name == 'pull_request' && env.IS_PR_FROM_FORK != 'true' }}
uses: ./.github/actions/javascript/generateHelpPreviewComment
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ROOT_URL: ${{ steps.deploy.outputs.deployment-url }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
- name: Leave a comment on the PR
uses: ./.github/actions/javascript/postOrReplaceComment
if: ${{ github.event_name == 'pull_request' && env.IS_PR_FROM_FORK != 'true' }}
with:
REPO: App
APP_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
COMMENT_PREFIX: A preview of your ExpensifyHelp changes have been deployed to
COMMENT_BODY: ${{ steps.preview_comment.outputs.BODY }}
notifyFailure:
name: Warn deployers if Expensify Help deploy failed
runs-on: blacksmith-2vcpu-ubuntu-2404
needs: build
if: ${{ failure() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
steps:
- name: Warn deployers if Expensify Help deploy failed
uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
with:
webhook: ${{ secrets.SLACK_WEBHOOK }}
webhook-type: incoming-webhook
payload: |
{
"channel": "#deployer",
"attachments": [{
"color": "#DB4545",
"pretext": "<!subteam^S4TJJ3PSL>",
"text": "Expensify Help <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|deploy> failed. Please fix it!"
}]
}