\chapter{Automated Manual Build} \ChapterLabel{AutomatedManualBuild} \index{Gitea Actions} \index{automated manual build} % --------------------------------------------------------------------------- % Bracketed italic text marks evidence that is added once the runner is online % and a real workflow run exists. Replace each placeholder with the actual % value or screenshot; do not fill them in before the run has happened. % --------------------------------------------------------------------------- \section{Source and Trigger} \textbf{Repository and files:} \begin{description} \item[Repository:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web} \item[Manual source folder:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/manual} \item[Main file:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/manual/devopsAssignment.tex} \item[Workflow:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/.gitea/workflows/manual.yml} \item[Tracking issue:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/8} \item[Pull request:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/9} \end{description} The manual is stored in the \texttt{manual/} folder of the team's existing product repository, Scrap-Web, rather than in a separate repository. The complete buildable project is version-controlled there: every chapter file, the \texttt{cornell.cls} document class, the \texttt{IEEEtran.bst} bibliography style, \texttt{devopsReferences.bib}, the glossary, and all figures under \texttt{HW2 images/} and \texttt{HW4 images/}. Generated files (PDF, \texttt{.aux}, \texttt{.log}, minted cache, and so on) are excluded by \texttt{manual/.gitignore}, so the repository holds source only. The repository is the source of truth; the PDF is never edited directly. \textbf{How the source was added:} the manual was committed on the branch \texttt{issue-8} (tracked by issue \#8), pushed to Gitea, and merged into \texttt{main} through a pull request. Work on the website itself happens on other branches and is unaffected. \textbf{Selected branch and event:} the workflow runs on a \texttt{push} to \texttt{main}. A path filter limits it to pushes that change \texttt{manual/**} or the workflow file itself, so website-only commits do not rebuild the manual. Merging a pull request into \texttt{main} counts as such a push. The workflow can also be started by hand from the Actions tab (\texttt{workflow\_dispatch}). \begin{figure} \centering \includegraphics[width=1\linewidth]{HW5 images/actions.png} \caption{10/09/26 Screenshot of Actions tab} \label{fig:actions} \end{figure} \textbf{Git remote and network path:} team members push over HTTPS. The remote is configured as: \begin{verbatim} $ git remote -v origin https://git.ssw590-08.me/SSW-590-08/Scrap-Web.git (fetch) origin https://git.ssw590-08.me/SSW-590-08/Scrap-Web.git (push) \end{verbatim} \begin{center} \begin{tabular}{lll} \toprule Hop & Port & Exposure \\ \midrule Laptop $\rightarrow$ Caddy (TLS proxy) & 443/TCP (HTTPS) & Public \\ Caddy $\rightarrow$ Gitea web service & 3000/TCP (HTTP) & Private Docker network only \\ \bottomrule \end{tabular} \end{center} A \texttt{git push} connects to \texttt{git.ssw590-08.me} on port 443, exactly as a browser does. Caddy terminates TLS and forwards the request over the internal Docker network to Gitea on port 3000, which is not published to the internet. Gitea's public root URL is set to \url{https://git.ssw590-08.me/}, so clone URLs and links point at the HTTPS hostname. SSH pushes are not needed for this assignment. \textbf{Why the runner needs no public port:} the runner never receives connections. It contacts Gitea outbound over HTTPS to register and to poll for jobs; the job then checks out the source and uploads the PDF over the same HTTPS URL. Because all traffic is initiated by the runner, no submission or management port has to be opened for it. \section{Runner Setup} Gitea Actions was enabled for the Scrap-Web repository to support automated builds of the DevOps IT manual. A Gitea Actions runner was registered to execute workflow jobs. The runner was configured with the label \texttt{latex}, allowing the workflow to select the appropriate execution environment through the \texttt{runs-on: latex} setting in \texttt{.gitea/workflows/manual.yml}. The runner uses \texttt{act\_runner} and executes the build job in a Docker container based on the custom image \texttt{latex-job:local}. This image provides the TeX Live environment and the additional tools required to compile the LaTeX document, including \texttt{latexmk}, \texttt{latexminted}, and Pygments. \subsection{Runner Details} The runner configuration is summarized below. \begin{itemize} \item \textbf{Location:} The runner was hosted on a local macOS computer using Docker Desktop, separate from the DigitalOcean Droplet hosting Gitea. \item \textbf{Version:} Gitea Actions runner \texttt{act\_runner} version 0.6.1. \item \textbf{Execution mode:} Docker-based job execution using the custom image \texttt{latex-job:local}. Each job runs in a temporary container. \item \textbf{Capacity:} One concurrent job, configured with \texttt{capacity: 1} in the runner configuration. \item \textbf{Registration scope:} The runner was registered for the repository's Actions workflow. The registration scope was configured through the Gitea repository's runner settings. \end{itemize} \subsection{Connectivity and Security} The runner connects to the Gitea instance at \texttt{https://git.ssw590-08.me}. The runner container uses the configured Gitea instance URL and Docker socket to retrieve workflow jobs and launch their job containers. Docker-based execution isolates the build environment from the Gitea application container. The Docker daemon socket is mounted inside the runner container so that it can create job containers; therefore, access to the socket is restricted to the trusted runner environment. No separate runner-management or Docker daemon port was intentionally exposed to the public internet. The runner communicates with Gitea over HTTPS, while the job environment must have network access to the resources required for the build. \subsection{Resource Considerations} The DigitalOcean Droplet hosting Gitea had approximately 458 MiB of total memory, with approximately 114 MiB available during the earlier resource check. Because this was limited memory, the LaTeX runner was placed on the local macOS computer rather than adding another resource-intensive service to the Droplet. This arrangement reduces the additional memory and disk load on the Gitea server while allowing the runner to use the custom Docker image required for the manual build. \subsection{Network Path and Runner Verification} The Gitea Actions runner operates on the local macOS computer using Docker Desktop. It connects to the Gitea instance at \texttt{https://git.ssw590-08.me} over HTTPS. The runner retrieves workflow jobs from Gitea and launches the assigned job in a Docker container using the custom image \texttt{latex-job:local}. The workflow targets the runner through the label \texttt{latex}, configured with \texttt{runs-on: latex}. The runner has a capacity of one concurrent job, allowing one workflow job to execute at a time. The runner uses the Docker socket to create job containers. The Docker daemon is not intentionally exposed through a public network port. Because access to the Docker socket provides substantial control over the Docker host, access is restricted to the trusted runner environment. Figure~\ref{fig:runner-job-assigned} provides evidence of the runner's status and its assignment to a workflow job. \begin{figure}[htbp] \centering \includegraphics[width=\linewidth] {HW5 images/runner-verification.png} \caption{Gitea Actions runner online with a workflow job assigned.} \label{fig:runner-job-assigned} \end{figure} \section{Reproducible Compilation} \begin{description} \item[Main file:] \texttt{manual/devopsAssignment.tex} \item[Build command:] \texttt{latexmk devopsAssignment.tex}, run in the \texttt{manual/} folder \item[Build configuration:] \texttt{manual/.latexmkrc} \item[Expected PDF path:] \texttt{manual/devopsAssignment.pdf} \item[Job image definition:] \texttt{manual/ci/Dockerfile} \item[Base image:] \texttt{texlive/texlive:TL2025-historic} \item[Resolved image ID/digest:] \textit{b5c35d6bdbb9} \end{description} \textbf{Where TeX runs:} the compiler is not installed in the Gitea container. The workflow targets the runner label \texttt{latex} (\texttt{runs-on: latex}), which maps to a job image built from \texttt{manual/ci/Dockerfile}. That image is the official TeX Live image, which already contains \texttt{pdflatex}, \texttt{latexmk}, \texttt{bibtex}, \texttt{makeindex}, \texttt{makeglossaries}, and Python with Pygments (needed by the \texttt{minted} package). The Dockerfile adds only Node.js and Git from the image's own Debian package repositories, which the checkout and upload actions require; no external script is downloaded and executed. The base image uses a fixed TeX Live release tag rather than \texttt{latest}, so every build uses the same toolchain. \textbf{Build command and dependencies:} all compiler options are stored in \texttt{manual/.latexmkrc}, so the same command works on a laptop and in the workflow: \begin{minted}[breaklines]{perl} $pdf_mode = 1; $pdflatex = 'pdflatex -shell-escape -interaction=nonstopmode -halt-on-error -file-line-error %O %S'; add_cus_dep('glo', 'gls', 0, 'run_makeglossaries'); add_cus_dep('acn', 'acr', 0, 'run_makeglossaries'); sub run_makeglossaries { return system("makeglossaries \"$_[0]\""); } \end{minted} \texttt{latexmk} runs \texttt{pdflatex} as many times as needed and calls \texttt{bibtex}, \texttt{makeindex}, and \texttt{makeglossaries} when their inputs change. \texttt{-shell-escape} is required by \texttt{minted}. \textbf{Workflow:} the complete workflow file, \texttt{.gitea/workflows/manual.yml}, is shown below. \begin{minted}[breaklines]{yaml} name: Build IT manual on: push: branches: [main] paths: - 'manual/**' - '.gitea/workflows/manual.yml' workflow_dispatch: jobs: build-manual: runs-on: latex defaults: run: shell: bash steps: - name: Check out the triggering commit uses: actions/checkout@v4 - name: Generate build metadata working-directory: manual env: GIT_COMMIT: ${{ github.sha }} BUILD_NUMBER: ${{ github.run_number }} run: | MANUAL_VERSION="v1.4" SHORT_SHA="${GIT_COMMIT:0:7}" BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}" cat > build-metadata.tex <> build-metadata.tex <<'EOF' \noindent\textbf{Manual version:} \ManualVersion\\ \textbf{Build identifier:} \BuildIdentifier\\ \textbf{Commit hash:} \BuildCommit\\ \textbf{Gitea Actions run:} \BuildRunNumber EOF - name: Record build identity and toolchain run: | SHORT_SHA="${GITHUB_SHA::7}" echo "SHORT_SHA=${SHORT_SHA}" >> "$GITHUB_ENV" echo "Commit: ${GITHUB_SHA} (${SHORT_SHA})" echo "Run number: ${GITHUB_RUN_NUMBER}" pdflatex --version | head -n 1 latexmk -v | head -n 2 | tail -n 1 python3 -c "import pygments; print('Pygments', pygments.__version__)" - name: Compile the manual working-directory: manual run: latexmk devopsAssignment.tex - name: Verify the PDF exists working-directory: manual run: | if [ ! -s devopsAssignment.pdf ]; then echo "ERROR: manual/devopsAssignment.pdf is missing or empty" exit 1 fi ls -l devopsAssignment.pdf - name: Upload the PDF as an artifact uses: actions/upload-artifact@v3 with: name: it-manual-build-${{ github.run_number }}-${{ env.SHORT_SHA }} path: manual/devopsAssignment.pdf if-no-files-found: error retention-days: 30 \end{minted} \textbf{Failure detection:} the build fails in three independent ways. \begin{enumerate} \item A LaTeX error stops \texttt{pdflatex} immediately (\texttt{-halt-on-error}); \texttt{latexmk} then exits with a non-zero code, which fails the \emph{Compile the manual} step. The log shows the failing file and line (\texttt{-file-line-error}). \item If compilation reports success but the PDF is missing or empty, the \emph{Verify the PDF exists} step exits with code 1 and prints an error. \item The upload step uses \texttt{if-no-files-found: error}, so it cannot silently upload nothing. \end{enumerate} A failed step stops the job, so no artifact is produced from a broken build. \textbf{Checkout and upload without a shared filesystem:} the job container shares no files with Gitea. The \texttt{actions/checkout} step clones the exact triggering commit from Gitea over HTTPS, the compile happens inside the temporary job container, and \texttt{actions/upload-artifact} sends the PDF back to Gitea over HTTPS, where it is attached to the matching run. The container is discarded when the job ends. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/run-build-log.png} \caption{Successful build log} \label{fig:run-log} \end{figure} \section{PDF Version Traceability} Every PDF produced by the workflow carries two kinds of version information: a \emph{human-maintained} manual version, which the team changes deliberately when the manual's content is revised, and a \emph{generated} build identifier, which the workflow creates automatically for every run. The build identifier appends the run number and the triggering commit to the manual version: \begin{center} \texttt{+build..} \end{center} \subsection{Build Identifier for Run \#10} The table below traces one build from its source commit to the finished PDF. \begin{tabularx}{\linewidth}{L{3.4cm}L{4.4cm}Y} \toprule \textbf{Field} & \textbf{Where it comes from} & \textbf{Value for run \#10}\\ \midrule Manual version & \texttt{MANUAL\_VERSION} in the \emph{Generate build metadata} step of \texttt{manual.yml}, edited by the team & \texttt{v1.4}\\ Workflow run number & \texttt{GITHUB\_RUN\_NUMBER}, set by Gitea Actions & \texttt{10}\\ Source commit & \texttt{GITHUB\_SHA}, the triggering commit, shortened to 7 characters & \texttt{67e9e17}\\ Build identifier & Combined by the workflow & \texttt{v1.4+build.10.67e9e17}\\ Gitea run & Actions tab & \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions/runs/10}\\ Artifact & Uploaded by the same run & \texttt{it-manual-build-10-67e9e17}\\ \bottomrule \end{tabularx} The same three values appear in three places: the run's log (Figure~\ref{fig:gitea-buildhash}), the artifact name, and the generated PDF itself (Figure~\ref{fig:pdf-buildhash}). In the PDF, the build identifier, full commit hash, and run number are printed on \textit{[the title page / in the page footer: state where]}. Because the commit hash in the PDF matches the commit listed on run \#10, a reader holding only the PDF can find the exact source revision that produced it. \subsection{How the Metadata Is Injected} The human-maintained version is set once, in the \emph{Generate build metadata} step of the workflow, and is kept equal to \texttt{\string\VERSION} on the title page. The team changes it only when the manual's content is revised, together with a new Document History entry. The run number and commit hash are never typed by hand: Gitea Actions supplies them to every job as \texttt{github.run\_number} and \texttt{github.sha}. Before compiling, the workflow combines these values and writes a small LaTeX file, \texttt{manual/build-metadata.tex}, inside the job container. The file defines four macros and a short block that prints them: \begin{minted}[breaklines]{yaml} - name: Generate build metadata working-directory: manual env: GIT_COMMIT: ${{ github.sha }} BUILD_NUMBER: ${{ github.run_number }} run: | MANUAL_VERSION="v1.4" SHORT_SHA="${GIT_COMMIT:0:7}" BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}" cat > build-metadata.tex <> build-metadata.tex <<'EOF' \noindent\textbf{Manual version:} \ManualVersion\\ \textbf{Build identifier:} \BuildIdentifier\\ \textbf{Commit hash:} \BuildCommit\\ \textbf{Gitea Actions run:} \BuildRunNumber EOF \end{minted} For run \#10 the generated file therefore defined \texttt{\string\BuildIdentifier} as \texttt{v1.4+build.10.67e9e17}. The manual reads the file during compilation: \begin{minted}[breaklines]{latex} run: | MANUAL_VERSION="v1.4" SHORT_SHA="${GIT_COMMIT:0:7}" BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}" cat > build-metadata.tex <> build-metadata.tex <<'EOF' \noindent\textbf{Manual version:} \ManualVersion\\ \textbf{Build identifier:} \BuildIdentifier\\ \textbf{Commit hash:} \BuildCommit\\ \textbf{Gitea Actions run:} \BuildRunNumber EOF \end{minted} The first \texttt{cat} uses an unquoted heredoc so that the shell substitutes the version, run number and commit into the macro definitions; the second uses a quoted heredoc (\texttt{<<'EOF'}) so that the LaTeX commands are written literally. \subsection{No Commit or Push Loop} The metadata file exists only inside the temporary job container, and \texttt{build-metadata.tex} is listed in \texttt{manual/.gitignore} so that a local test build cannot commit it by accident. The workflow contains no \texttt{git commit} or \texttt{git push} step, so the generated version is never written back to \texttt{main}; the container and the file are discarded when the job ends. This matters because the workflow is triggered by pushes to \texttt{main}: a workflow that committed its own version file would trigger itself again on every build. The human-maintained version and the Document History table therefore stay entirely under the team's control, and change only when a team member edits them. \subsection{Re-runs} Re-running a workflow in Gitea keeps the same run number and checks out the same commit, so a re-run produces a PDF with the same build identifier. Because the source is identical, the team treats such a re-run as the same build, and the run-attempt number is not included in the identifier. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/gitea-buildhash.png} \caption{Gitea build report} \label{fig:gitea-buildhash} \end{figure} \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/pdf-buildhas.png} \caption{PDF compiled build report} \label{fig:pdf-buildhash} \end{figure} \section{Downloadable Artifact} \begin{description} \item[Artifact name:] \texttt{it-manual-build-\textit{N}-\textit{H}}, where \textit{N} is the workflow run number and \textit{H} is the short commit hash; for example, \texttt{it-manual-build-12-a1b2c3d} \item[Contents:] \texttt{devopsAssignment.pdf} \item[Retention:] 30 days, set in the workflow (\texttt{retention-days: 30}). \item[Example artifact link:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions/runs/10/artifacts/it-manual-build-10-67e9e17} \end{description} Because the run number and commit hash are part of the artifact name, each downloaded file can be matched to the run and commit that produced it. \textbf{How a team member downloads the PDF:} \begin{enumerate} \item Open \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions}. \item Select the \emph{Build IT manual} workflow and open the run for the commit of interest (the run lists its commit hash and branch). \item Confirm the run finished successfully. \item In the run's \emph{Artifacts} section, click \texttt{it-manual-build-\ldots} to download it, then extract and open \texttt{devopsAssignment.pdf}. \end{enumerate} Artifacts expire after the retention period and are not a backup. The permanent record is the LaTeX source in Git, from which any version of the manual can be rebuilt. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/gitea-running-artifact.png} \caption{Run page with the artifact listed, and the downloaded PDF open, dated} \label{fig:fig:gitea-artifact-running} \end{figure} \section{Change, Failure, and Repair Evidence} To verify the automated manual-build pipeline, two successive changes were committed to the main branch of the Scrap-Web repository. Each commit triggered a separate Gitea Actions run. Both builds completed successfully, and the generated PDF artifacts were checked to confirm that their build identifiers corresponded to the appropriate commits and run numbers. A deliberate LaTeX error was then introduced into the manual source. The workflow detected the compilation error and terminated with a failed status because the build uses the -halt-on-error option. The failed run and its error log were recorded as evidence that the pipeline prevents an invalid manual from being treated as a successful build. The invalid command was subsequently removed in a repair commit. A new Actions run compiled the corrected source successfully and produced a new PDF artifact. The repaired artifact's commit hash and run number were compared with the corresponding Gitea Actions run to verify that the output was generated from the repaired revision. The generated metadata was produced during the workflow rather than committed back to the source branch. This kept the build identifier associated with the specific build while preserving the distinction between source commits and generated artifacts. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/run-build-log.png} \caption{Run log showing 2 successive builds, followed by an error, and another successful build} \label{fig:buildlogs} \end{figure} \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/errormessage.png} \caption{Failed build error message} \label{fig:error-message} \end{figure} \section{Runner and Secret Boundary} \subsection{Workflow edit permissions} The automated build workflow is stored in .gitea/workflows/manual.yml. Users who can modify the workflow may change the commands executed by the runner. Repository write permissions and any branch-protection rules were reviewed to identify who can modify the workflow and its associated source files. The repository's actual permissions and branch-protection configuration are recorded in the accompanying evidence. \subsection{Runner registration credentials} The Gitea Actions runner is hosted on the local macOS development machine. Its configuration is stored in ~/gitea-runner/runner-data/config.yaml, and its local runner credentials are stored in the runner-data directory, including the .runner file when present. These files are not included in the report or committed to the repository because they may contain sensitive authentication information. The registration token is used to register the runner; it is distinct from the credentials subsequently stored by the registered runner. \subsection{Runner isolation} The runner uses the latex label, which matches the workflow's runs-on: latex setting. The runner executes the manual-build job in a Docker container based on the custom latex-job:local image. Its configured capacity is one job at a time. Hosting the runner on the development machine rather than the DigitalOcean Gitea server avoids placing the additional build workload on the server's limited memory and disk resources. Containerization provides isolation for the build environment, but it is not treated as a complete security boundary. \subsection{Docker socket risk} The runner container has access to the Docker Desktop socket so that it can create job containers. Access to this socket is security-sensitive because it may allow control over Docker resources and potentially affect the host system. The socket is mounted locally for runner operation rather than deliberately exposed as a public network endpoint. The runner is therefore restricted to trusted coursework workflows, and its credentials and configuration files are kept out of source control. Evidence includes the repository permission settings, runner configuration with secrets omitted, and the runner's Docker configuration. No authentication tokens or credential values are reproduced in this report. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/adminpage.png} \caption{Listed repo admins} \label{fig:admin-perms} \end{figure} \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/ownerpage.png} \caption{Listed repo owners} \label{fig:owner-perms} \end{figure} \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/tokenlocations.png} \caption{Verification of token existence} \label{fig:tokenlocations} \end{figure} \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/twosuccessruns.png} \caption{Two Successive Runs} \label{fig:successfulruns} \end{figure} \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{HW5 images/pdfidentifiers.png} \caption{Associated PDF identifiers} \label{fig:pdfidentify} \end{figure} \section{Manual Quality and Controls} \subsection{Common Troubleshooting Methods} Throughout this exercise, there came many times where the builds failed (around 8 times). The main method of troubleshooting involved checking version statuses, updating and restarting file instances, and parsing of error messages to pinpoint.