generated from riscv/docs-spec-template
-
Notifications
You must be signed in to change notification settings - Fork 30
122 lines (106 loc) · 3.44 KB
/
build-pdf.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
---
name: Create Specification Document
# The workflow is triggered by pull request, push to main, and manual dispatch.
on:
workflow_dispatch:
inputs:
version:
description: 'Release version, e.g. X.Y.Z:'
required: true
type: string
revision_mark:
description: 'Set revision mark as Draft, Release or Stable:'
required: true
type: choice
options:
- Draft
- Release
- Stable
default: Draft
prerelease:
description: Tag as a pre-release?
required: false
type: boolean
default: true
draft:
description: Create release as a draft?
required: false
type: boolean
default: false
pull_request:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
# Pull the latest RISC-V Docs container image
- name: Pull Container
run: docker pull riscvintl/riscv-docs-base-container-image:latest
# Override VERSION and REVMARK for manual workflow dispatch
- name: Update environment variables for releases
run: |
echo "VERSION=v${{ github.event.inputs.version }}" >> "$GITHUB_ENV"
echo "REVMARK=${{ github.event.inputs.revision_mark }}" >> "$GITHUB_ENV"
if: github.event_name == 'workflow_dispatch'
- name: Update environment variables for push events
run: |
echo "EXTRA_ASCIIDOC_OPTIONS=-a github_commit_sha=$GITHUB_SHA" >> "$GITHUB_ENV"
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# Build PDF and HTML.
- name: Build Files
run: make all
# Upload the built PDF and HTML files as a single artifact
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: Build Artifacts
path: |
build/*.pdf
build/*.html
retention-days: 30
# Upload GitHub pages artefacts.
- name: Make gitlab pages directory
run: mkdir dist && cp build/*.html dist/index.html
if: github.event_name == 'push'
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
# Create Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
build/*.pdf
build/*.html
tag_name: v${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.version }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GHTOKEN }}
if: github.event_name == 'workflow_dispatch'
# This condition ensures this step only runs for workflow_dispatch events.
# Deploy HTML to Github pages.
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4