forked from PalisadoesFoundation/talawa-api
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (105 loc) · 4.59 KB
/
push-documentation.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
##############################################################################
##############################################################################
#
# NOTE!
#
# Please read the README.md file in this directory that defines what should
# be placed in this file
#
##############################################################################
##############################################################################
name: Push Documentation Workflow
on:
push:
branches-ignore:
- '*'
jobs:
##############################################################################
# This section is added so that the Talawa Docs repository and Talawa API
# are both updated with the latest schema docs post merge.
##############################################################################
Push-Workflow:
name: Updating Documentation
runs-on: ubuntu-latest
environment: TALAWA_ENVIRONMENT
strategy:
matrix:
node-version: [20.x]
services:
mongo:
image: mongo:4.4
options: >-
--health-cmd mongo
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 27017:27017
env:
MONGO_DB_URL: mongodb://localhost:27017/talawa-test-db
# ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
# REFRESH_TOKEN_SECRET: ${{ secrets.REFRESH_TOKEN_SECRET }}
# We checkout the content of the Talawa-API repository in a directory called `api`
# This is done as we will use the Talawa-Docs repository later too
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.TALAWA_DOCS_SYNC }}
path: api
- name: Generate Access Token Secret
run: echo "ACCESS_TOKEN_SECRET=$(openssl rand -hex 32)" >> $GITHUB_ENV
- name: Generate Refresh Token Secret
run: echo "REFRESH_TOKEN_SECRET=$(openssl rand -hex 32)" >> $GITHUB_ENV
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
# Move into the api folder before installing the dependencies
- name: Install dependencies
run: cd api && npm ci
# Move into the api folder before starting the server
- name: Start the development server in detach mode
run: |
cd api && npm run dev &
echo "Development server started..."
# Sleep for 10 s
- name: Sleep for 10s
uses: juliangruber/sleep-action@v2
with:
time: 10s
# Move into the api folder before generating the Markdown schema documentation
- name: Generate the GraphQL-Markdown documentation
run: cd api && npm run generate:graphql-markdown
# Move into the api folder before generating the Schema is json form
- name: Genrate the GraphQL Schema in JSON form
run: cd api && npm run generate:graphql-schema
# Running the generate::** scripts will create the necessary documentation on the server
# where the GitHub Action is running locally. We add the same to stage with -f flag as they are a
# part of the .gitignore file
- name: Add the generated Markdown Documentation to stage
run: cd api && git add docs/Schema.md -f
# We use this action to commit the changes above to the repository
- name: Commit generated Markdown Documentation to the Talawa API repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Generate GraphQL Schema and Markdown Documentation
repository: api
# We will clone the Talawa Docs in the folder called docs so that we can copy the generated
# schema.json into the same later
- name: Checkout the Talawa-Docs repository
uses: actions/checkout@v4
with:
repository: PalisadoesFoundation/talawa-docs
token: ${{ secrets.TALAWA_DOCS_SYNC }}
path: docs
# Copy the generated schema.json into the Talawa Docs repository
- name: Sync schema.json from Talawa API to Talawa Docs
run: cp api/docs/schema.json docs/docs/github-actions/
# Add the updated schema.json in Talawa Docs to stage
- name: Add the synced schema.json to stage in Talawa Docs
run: cd docs && git add docs/github-actions/schema.json
# Commit the changes made to schema.json into Talawa Docs
- name: Commit the synced schema to the Talawa Docs repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update schema.json
repository: docs