Skip to content

Commit 3365382

Browse files
sahithiacnbors-diem
authored andcommitted
[github] Automatically generate the Book
Closes: #448
1 parent 18baba2 commit 3365382

File tree

2 files changed

+24
-110
lines changed

2 files changed

+24
-110
lines changed

.github/workflows/ci-post-land.yml

Lines changed: 19 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,30 @@
1+
# CI jobs to be run upon the code lands to the main branch or GitHub Action test branches.
2+
13
name: ci-post-land
24

35
on:
4-
create:
5-
branches: [main, release-*]
66
push:
7-
branches: [main, release-*, gha-test-*]
8-
9-
defaults:
10-
run:
11-
shell: bash
12-
13-
env:
14-
max_threads: 16
15-
pre_command: cd /opt/git/diem/
7+
branches: [main, gha-test-*]
168

179
jobs:
18-
prepare:
10+
generate-documentation:
11+
name: Generate the Move Book using mdBook
1912
runs-on: ubuntu-20.04
20-
outputs:
21-
changes-target-branch: ${{ steps.changes.outputs.changes-target-branch }}
22-
changes-base-git-rev: ${{ steps.changes.outputs.changes-base-git-rev }}
23-
changes-base-githash: ${{ steps.changes.outputs.changes-base-githash }}
24-
changes-pull-request-number: ${{ steps.changes.outputs.changes-pull-request-number }}
25-
rust-changes: ${{ steps.rust-changes.outputs.changes-found }}
26-
base-image-changes: ${{ steps.base-image-changes.outputs.changes-found }}
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
2715
steps:
28-
- uses: actions/[email protected]
29-
with:
30-
# This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
31-
# On `push` this value will be empty and will "do-the-right-thing"
32-
ref: ${{ github.event.pull_request.head.sha }}
33-
fetch-depth: 0 #get all the history!!!
34-
- name: Git Hooks and Checks
35-
run: ./scripts/git-checks.sh
36-
- id: changes
37-
name: determine changes
38-
uses: diem/actions/changes@faadd16607b77dfa2231a8f366883e01717b3225
39-
with:
40-
workflow-file: ci-post-land.yml
41-
github-token: ${{secrets.GITHUB_TOKEN}}
42-
- id: rust-changes
43-
name: find rust/cargo changes.
44-
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
45-
with:
46-
pattern: '^documentation\|^docker\|^scripts\|^developers.diem.com'
47-
invert: "true"
48-
- id: base-image-changes
49-
name: find dev-setup.sh/base docker image changes
50-
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
51-
with:
52-
pattern: '.github/workflows/ci-post-land.yml\|.github/actions/dockerhub_login/action.yml\|docker/ci/github/Dockerfile\|scripts/dev_setup.sh\|rust-toolchain'
16+
- uses: actions/checkout@v2
5317

54-
build_ci_base_docker_image:
55-
needs: prepare
56-
runs-on: ubuntu-20.04-xl
57-
if: ${{ needs.prepare.outputs.base-image-changes == 'true' || github.event_name == 'create' }}
58-
env:
59-
REGISTRY: ghcr.io
60-
IMAGE_NAME: ${{ github.repository }}_build_environment
61-
IMAGE_TAG: ${{ needs.prepare.outputs.changes-target-branch }}
62-
steps:
63-
- uses: actions/[email protected]
64-
with:
65-
# This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
66-
# On `push` this value will be empty and will "do-the-right-thing"
67-
ref: ${{ github.event.pull_request.head.sha }}
68-
fetch-depth: 0 #get all the history!!!
69-
- name: Log in to the Container registry
70-
uses: docker/login-action@v1
18+
- name: Setup mdBook
19+
uses: peaceiris/actions-mdbook@v1
7120
with:
72-
registry: ${{ env.REGISTRY }}
73-
username: ${{ github.actor }}
74-
password: ${{ secrets.GITHUB_TOKEN }}
75-
- name: build image
76-
run: docker build -f docker/ci/github/Dockerfile -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} .
77-
- name: Push to ghcr
78-
run: |
79-
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
21+
mdbook-version: '0.4.10'
22+
# mdbook-version: 'latest'
8023

81-
# rustdoc:
82-
# needs: prepare
83-
# if: ${{ needs.prepare.outputs.changes-target-branch == 'main' && needs.prepare.outputs.rust-changes == 'true'}}
84-
# runs-on: ubuntu-20.04
85-
# container:
86-
# image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }}
87-
# volumes:
88-
# - "${{github.workspace}}:/opt/git/diem"
89-
# steps:
90-
# - name: Checkout repository
91-
# uses: actions/[email protected]
92-
# - uses: ./.github/actions/build-setup
93-
# - uses: actions/[email protected]
94-
# with:
95-
# path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
96-
# key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
97-
# restore-keys: "crates-${{ runner.os }}"
98-
# - name: Build Documentation
99-
# # Build the rust crate docs
100-
# # Use `RUSTC_BOOTSTRAP` in order to use the `--enable-index-page` flag of rustdoc
101-
# # This is needed in order to generate a landing page `index.html` for workspaces
102-
# run: cargo doc --no-deps --workspace --lib
103-
# env:
104-
# RUSTC_BOOTSTRAP: 1
105-
# RUSTDOCFLAGS: "-Z unstable-options --enable-index-page"
106-
# CARGO_INCREMENTAL: 0
107-
# RUSTFLAGS: -D warnings
108-
# - name: copy API specification doc into target/doc/diem_api
109-
# run : cp api/doc/openapi.yaml target/doc/diem_api/openapi.yaml && cp api/doc/spec.html target/doc/diem_api/spec.html
110-
# - name: Deploy Docs
111-
# uses: peaceiris/[email protected]
112-
# with:
113-
# github_token: ${{ secrets.GITHUB_TOKEN }}
114-
# publish_branch: gh-pages
115-
# publish_dir: ./target/doc
116-
# force_orphan: true
24+
- run: mdbook build language/documentation/book
25+
26+
- name: Deploy
27+
uses: peaceiris/actions-gh-pages@v3
28+
with:
29+
github_token: ${{ secrets.GITHUB_TOKEN }}
30+
publish_dir: ./language/documentation/book/book

.github/workflows/ci-test.yml renamed to .github/workflows/ci-pre-land.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: ci-test
1+
# CI jobs to be run upon the code lands to the main branch or GitHub Action test branches.
2+
3+
name: ci-pre-land
24

35
on:
4-
push:
5-
branches: [auto, canary, gha-test-*]
66
pull_request:
7-
branches: [main, release-*, gha-test-*]
7+
branches: [main, gha-test-*]
88

99
defaults:
1010
run:
@@ -39,7 +39,7 @@ jobs:
3939
name: determine changes
4040
uses: diem/actions/changes@faadd16607b77dfa2231a8f366883e01717b3225
4141
with:
42-
workflow-file: ci-test.yml
42+
workflow-file: ci.yml
4343
github-token: ${{secrets.GITHUB_TOKEN}}
4444
- id: any-changes-found
4545
name: determine if there are any files listed in the CHANGES_CHANGED_FILE_OUTPUTFILE.

0 commit comments

Comments
 (0)