This repository has been archived by the owner on Feb 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
86 lines (77 loc) · 2.58 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
name: Build Document PDF
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type (draft or regular)'
required: true
type: string
default: 'regular'
version:
description: 'Release version, e.g. X.Y.Z:'
required: true
type: string
target_branch:
description: 'Target branch to run the workflow on'
required: true
default: 'main'
pull_request:
branches:
- '*'
push:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.target_branch }}
# Pull the latest RISC-V Docs container image
# https://github.com/riscv/riscv-docs-base-container-image
# https://hub.docker.com/r/riscvintl/riscv-docs-base-container-image
- name: Pull Container
run: |
docker pull riscvintl/riscv-docs-base-container-image:latest
# Build PDF file using the container
- name: Build Files
id: build_files
run: |
docker run --rm -v ${{ github.workspace }}:/build riscvintl/riscv-docs-base-container-image:latest \
/bin/sh -c 'make'
# Set the short SHA and repo name for use in artifact names
- name: Set short SHA and repo name
run: |
echo "SHORT_SHA=$(echo ${GITHUB_SHA::7})" >> $GITHUB_ENV
echo "REPO_NAME=$(echo ${GITHUB_REPOSITORY##*/})" >> $GITHUB_ENV
# Upload the built PDF files as individual artifacts
- name: Upload Build Artifacts
run: |
for file in ${{ github.workspace }}/*.pdf; do
filename=$(basename "$file")
echo "Uploading $filename"
echo "ARTIFACT_NAME=$filename" >> $GITHUB_ENV
echo "ARTIFACT_PATH=$file" >> $GITHUB_ENV
done
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_PATH }}
retention-days: 7
- name: Create Release
if: steps.build_files.outcome == 'success' && github.event_name == 'workflow_dispatch' && github.event.inputs.release_type != ''
uses: softprops/action-gh-release@v1
with:
draft: ${{ github.event.inputs.release_type == 'draft' }}
tag_name: v${{ github.event.inputs.version }}
name: ${{ env.CURRENT_DATE }}
body: |
This release was created by: ${{ github.event.sender.login }}
files: |
${{ github.workspace }}/*.pdf
env:
GITHUB_TOKEN: ${{ secrets.GHTOKEN }}