-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (116 loc) · 3.97 KB
/
release-docs.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
name: 🚀release-docs
on:
workflow_dispatch:
inputs:
permissions:
id-token: write
contents: read
env:
DOGU_AWS_REGION: ap-northeast-2
DOCS_GA_ID: G-5WLY043T9W
jobs:
build:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Yarn Unplugged
uses: actions/cache@v3
id: cache_yarn_unplugged
env:
cache-name: cache-yarn-unplugged
with:
path: ${{ github.workspace }}/.yarn/unplugged
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Write env for production
run: echo "GOOGLE_ANALYTICS_ID=$GOOGLE_ANALYTICS_ID" >> ./docs/.env
env:
GOOGLE_ANALYTICS_ID: ${{ env.DOCS_GA_ID }}
- name: Build docs
run: yarn build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.DOGU_AWS_REGION }}
- name: Login to Amazon ECR Private
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: true
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
context: ./
tags: ${{ steps.login-ecr.outputs.registry }}/prod-dogu-docs:latest
platforms: linux/amd64
target: dogu-docs
release:
runs-on: dogu-docs
needs: build
steps:
- name: docker init
run: |
docker ps -qa | xargs -r docker rm -f
docker system prune --volumes -a -f
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.DOGU_AWS_REGION }}
- name: Login to Amazon ECR Private
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: true
- name: Run
run: |
docker pull ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.DOGU_AWS_REGION }}.amazonaws.com/prod-dogu-docs:latest
CONTAINERS=$(docker ps -a -q)
if [ -n "$CONTAINERS" ]; then
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker run -d -p 3100:3100 ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.DOGU_AWS_REGION }}.amazonaws.com/prod-dogu-docs:latest
docker image prune -f
else
docker run -d -p 3100:3100 ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.DOGU_AWS_REGION }}.amazonaws.com/prod-dogu-docs:latest
docker image prune -f
fi
crawl-docs:
runs-on: ubuntu-latest
needs: release
steps:
- name: Algolia recrawl
uses: algolia/[email protected]
id: algolia_crawler
with:
crawler-user-id: ${{ secrets.DOCS_CRAWLER_USER_ID }}
crawler-api-key: ${{ secrets.DOCS_CRAWLER_API_KEY }}
algolia-app-id: ${{ secrets.DOCS_ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.DOCS_ALGOLIA_API_KEY }}
site-url: 'https://docs.dogutech.io'
crawler-name: 'dogutech'
send-slack:
runs-on: ubuntu-latest
needs: crawl-docs
if: ${{ always() }}
steps:
- name: Send Slack
uses: dogu-team/[email protected]
with:
template: 'CD'
slack-channel-id: 'C057ML9UH34'
result-status: ${{ needs.crawl-docs.result }}
ignore-notify: false
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}