Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable CI/CD #3

Merged
merged 33 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
598942b
chore: update Dockerfile for new ubuntu image/tex
kevin-secrist Jan 5, 2025
2371530
ci: github actions for building docker and docs
kevin-secrist Jan 5, 2025
63535bf
chore: update vscode/local settings for consistency
kevin-secrist Jan 5, 2025
743e72a
fix: use -- in git diff
kevin-secrist Jan 5, 2025
92e612b
ci: fix event criteria
kevin-secrist Jan 5, 2025
64f883c
fix: use different ref spec
kevin-secrist Jan 5, 2025
23ffbb2
fix: checkout full history of repo
kevin-secrist Jan 5, 2025
905aab5
fix: inverted if
kevin-secrist Jan 5, 2025
03d3aa2
test: debug gh output
kevin-secrist Jan 5, 2025
dd1cce0
fix: outputs are strings
kevin-secrist Jan 5, 2025
3f2551f
ci: enable docker caching
kevin-secrist Jan 5, 2025
4f0cfd6
chore: label docker image
kevin-secrist Jan 5, 2025
4524a4d
chore: set up buildx for caching
kevin-secrist Jan 5, 2025
82e7c08
fix: don't push to docker registry
kevin-secrist Jan 5, 2025
3c82bf8
dev: use ghcr image for dev container
kevin-secrist Jan 5, 2025
1fd1538
ci: grant package write permissions
kevin-secrist Jan 5, 2025
cb62ff3
ci: use github workspace inside container
kevin-secrist Jan 5, 2025
004992a
chore: remove unused TZ setup
kevin-secrist Jan 5, 2025
b4c02b6
ci: use gha user inside container
kevin-secrist Jan 5, 2025
bbed779
fix: specify relative path for build script
kevin-secrist Jan 5, 2025
f23760d
chore: remove references to undefined env vars
kevin-secrist Jan 5, 2025
33ad364
ci: fail if no artifacts uploaded
kevin-secrist Jan 5, 2025
d7718cb
test: inspect filesystem, paths are unexpected
kevin-secrist Jan 5, 2025
5e23d03
fix: github.workspace seems to be unreliable here
kevin-secrist Jan 5, 2025
d5cc8d1
fix: properly capture logs in artifacts
kevin-secrist Jan 5, 2025
0697ca5
fix: include artifact name when downloading
kevin-secrist Jan 5, 2025
ad958c2
feat: include auto-incrementing version
kevin-secrist Jan 5, 2025
52da6f6
feat: use incremented version during build
kevin-secrist Jan 5, 2025
7f9d041
fix: just use git instead of api
kevin-secrist Jan 5, 2025
8b95182
fix: also include git history
kevin-secrist Jan 5, 2025
4d978d1
fix: git not installed, install jq and use_api instead
kevin-secrist Jan 5, 2025
7194f1a
fix: also include git
kevin-secrist Jan 6, 2025
0de164a
feat: only release on main branch
kevin-secrist Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
]
}
},
"dockerFile": "../Dockerfile",
"context": "../src",
"image": "ghcr.io/kevin-secrist/latex:latest",
"workspaceMount": "source=${localWorkspaceFolder},target=/data,type=bind,consistency=cached",
"workspaceFolder": "/data",
"runArgs": [ ]
Expand Down
107 changes: 107 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
on:
pull_request:
push:
branches: main

permissions:
contents: write
packages: write

jobs:
build-docker:
runs-on: ubuntu-latest
name: Build Docker Image
outputs:
tag: ${{ steps.select_image.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Select Docker Image
id: select_image
shell: bash
run: |
ref=${{ github.ref_name }}
status=$(git diff --exit-code origin/main Dockerfile > /dev/null && echo "unchanged" || echo "changed")
if [[ "$ref" = "main" ]]; then
echo "build_image=true" >> "$GITHUB_OUTPUT";
echo "tag=latest" >> "$GITHUB_OUTPUT";
else
if [[ "$status" = "changed" ]]; then
echo "tag=$GITHUB_SHA" >> "$GITHUB_OUTPUT";
echo "build_image=true" >> "$GITHUB_OUTPUT";
else
echo "tag=latest" >> "$GITHUB_OUTPUT";
echo "build_image=false" >> "$GITHUB_OUTPUT";
fi;
fi;
- name: Login to GitHub Container Registry
if: steps.select_image.outputs.build_image == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
if: steps.select_image.outputs.build_image == 'true'
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ github.repository_owner }}/latex:${{ steps.select_image.outputs.tag }}

build-documents:
runs-on: ubuntu-latest
needs: build-docker
name: Build Documents
container:
image: ghcr.io/${{ github.repository_owner }}/latex:${{ needs.build-docker.outputs.tag }}
options: --user 1001
outputs:
version: ${{ steps.version.outputs.v-version }}
steps:
- uses: actions/checkout@v4
- name: Get next version
uses: reecetech/[email protected]
id: version
with:
use_api: true
scheme: conventional_commits
increment: patch
- name: Build with container
run: ./build.sh
working-directory: ./src
env:
VERSION: ${{ steps.version.outputs.v-version }}
- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: output
path: |
./src/out/*.log
./src/out/*.pdf
release:
name: Release
needs: build-documents
if: github.ref_name == 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: output
pattern: "*.pdf"
- uses: softprops/action-gh-release@v2
with:
name: ${{ needs.build-documents.outputs.version }}
tag_name: ${{ needs.build-documents.outputs.version }}
generate_release_notes: true
make_latest: true
fail_on_unmatched_files: true
files: |
secrist-resume.pdf
secrist-cv.pdf
29 changes: 29 additions & 0 deletions .github/workflows/scheduled-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
schedule:
- cron: "0 16 * * 2"

permissions:
packages: write

jobs:
build-docker:
runs-on: ubuntu-latest
name: Build Docker Image
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ github.repository_owner }}/latex:latest
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"latex-workshop.latex.outDir": "%DIR%/../out",
"latex-workshop.latex.outDir": "%DIR%/out",
"latex-workshop.latex.recipes": [
{
"name": "latexmk",
Expand Down
103 changes: 46 additions & 57 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,57 +1,46 @@
FROM ubuntu:jammy

ARG USERNAME=latex
ARG UID=1000
ARG GID=$UID
RUN groupadd --gid $GID $USERNAME \
&& useradd --uid $UID --gid $GID -m $USERNAME

ARG TZ
ENV TZ="$TZ"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update \
&& apt-get install -y build-essential wget curl libfontconfig1 tzdata \
&& rm -rf /var/lib/apt/lists/*

ARG TEXLIVE_MIRROR=https://mirror.ctan.org/systems/texlive/tlnet
ENV MANPATH "${MANPATH}:/usr/local/texlive/2023/texmf-dist/doc/man"
ENV INFOPATH "${INFOPATH}:/usr/local/texlive/2023/texmf-dist/doc/info"
ENV PATH "${PATH}:/usr/local/texlive/2023/bin/x86_64-linux"

RUN mkdir /install-tl-unx \
&& curl -sSL \
${TEXLIVE_MIRROR}/install-tl-unx.tar.gz \
| tar -xzC /install-tl-unx --strip-components=1 \
\
&& echo "tlpdbopt_autobackup 0" >> /install-tl-unx/texlive.profile \
&& echo "tlpdbopt_install_docfiles 0" >> /install-tl-unx/texlive.profile \
&& echo "tlpdbopt_install_srcfiles 0" >> /install-tl-unx/texlive.profile \
&& echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile \
\
&& /install-tl-unx/install-tl \
-profile /install-tl-unx/texlive.profile \
-repository ${TEXLIVE_MIRROR} \
&& rm -rf /install-tl-unx
RUN tlmgr install --repository ${TEXLIVE_MIRROR} \
latexmk \
texcount \
luatexbase \
luainputenc \
environ \
trimspaces \
fontspec \
parskip \
xcolor \
preprint \
fontawesome5 \
titlesec \
enumitem \
etoolbox \
pgf \
tcolorbox \
tikzfill

USER $USERNAME
WORKDIR /data/src
VOLUME ["/data"]
FROM ubuntu:noble

RUN apt-get update \
&& apt-get install -y build-essential wget curl libfontconfig1 tzdata jq git \
&& rm -rf /var/lib/apt/lists/*

ARG TEXLIVE_MIRROR=https://mirror.ctan.org/systems/texlive/tlnet
ENV MANPATH="/usr/local/texlive/2024/texmf-dist/doc/man" \
INFOPATH="/usr/local/texlive/2024/texmf-dist/doc/info" \
PATH="${PATH}:/usr/local/texlive/2024/bin/x86_64-linux"

RUN mkdir /install-tl-unx \
&& curl -sSL \
${TEXLIVE_MIRROR}/install-tl-unx.tar.gz \
| tar -xzC /install-tl-unx --strip-components=1 \
\
&& echo "tlpdbopt_autobackup 0" >> /install-tl-unx/texlive.profile \
&& echo "tlpdbopt_install_docfiles 0" >> /install-tl-unx/texlive.profile \
&& echo "tlpdbopt_install_srcfiles 0" >> /install-tl-unx/texlive.profile \
&& echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile \
\
&& /install-tl-unx/install-tl \
-profile /install-tl-unx/texlive.profile \
-repository ${TEXLIVE_MIRROR} \
&& rm -rf /install-tl-unx
RUN tlmgr install --repository ${TEXLIVE_MIRROR} \
latexmk \
texcount \
luatexbase \
luainputenc \
environ \
trimspaces \
fontspec \
parskip \
xcolor \
preprint \
fontawesome5 \
titlesec \
enumitem \
etoolbox \
pgf \
tcolorbox \
tikzfill

LABEL org.opencontainers.image.source=https://github.com/kevin-secrist/resume
LABEL org.opencontainers.image.description="Basic LaTeX image for building a resume"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If you prefer to develop without VS Code, or without the containers extension, y

```bash
docker build -t latex-build .
docker run -v $PWD:/data latex-build /data/src/build.sh
docker run -v $PWD:/data -w /data/src latex-build ./build.sh
```

# Inspirations
Expand Down
4 changes: 2 additions & 2 deletions src/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
latexmk -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=/data/out /data/src/secrist-resume
latexmk -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=/data/out /data/src/secrist-cv
latexmk -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=out secrist-resume
latexmk -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=out secrist-cv
1 change: 0 additions & 1 deletion src/latexmkrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
$ENV{'TZ'}='America/New_York';
$ENV{'VERSION'}='v1.0.5';
2 changes: 1 addition & 1 deletion src/secrist-coverletter.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% !TEX TS-program = latexmk
% !TEX options = -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=/data/out /data/src/secrist-coverletter
% !TEX options = -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=src/out src/secrist-coverletter

\documentclass[localFont,alternative,compact]{yaac-another-awesome-cv}
\selectlanguage{english}
Expand Down
2 changes: 1 addition & 1 deletion src/secrist-cv.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% !TEX TS-program = latexmk
% !TEX options = -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=/data/out /data/src/secrist-cv
% !TEX options = -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=src/out src/secrist-cv

\documentclass[localFont,alternative,compact]{yaac-another-awesome-cv}
\selectlanguage{english}
Expand Down
2 changes: 1 addition & 1 deletion src/secrist-resume.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% !TEX TS-program = latexmk
% !TEX options = -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=/data/out /data/src/secrist-resume
% !TEX options = -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=src/out src/secrist-resume

\documentclass[localFont,alternative,compact]{yaac-another-awesome-cv}
\selectlanguage{english}
Expand Down
Loading