This repository has been archived by the owner on Feb 29, 2024. It is now read-only.
Merge pull request #225 from jnk0le/adoc_compress #126
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |