Skip to content

Commit

Permalink
CI: update stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
anishshobithps committed Jan 11, 2025
1 parent b67dbc2 commit 670da75
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 58 deletions.
45 changes: 22 additions & 23 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
# Stage 1: Install TeX Live and dependencies (Cached)
FROM alpine:latest AS builder

# Install system dependencies (these rarely change)
RUN apk add --no-cache git bash wget

# Install texlive and other tex related packages to cache
RUN apk add --no-cache \
texlive \
texlive-latex \
texlive-latex-extra \
texlive-fonts-extra \
texlive-xetex \
texlive-bibtex-extra \
latexmk \
--repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/main

# Stage 2: Final Image (Smaller and Faster)
# Stage 1: TeX Live Base
FROM alpine:latest AS builder-texlive

RUN apk add --no-cache git bash wget perl # Perl is required by tlmgr
RUN apk add --no-cache texlive --repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/main
ENV PATH="/usr/local/texlive/2023/bin/x86_64-linux:$PATH"
RUN tlmgr update --self
RUN tlmgr option repository http://mirror.ctan.org/systems/texlive/tlnet

# Stage 2: Fonts and Packages
FROM builder-texlive AS builder-fonts

RUN tlmgr install xcharter
RUN tlmgr install enumitem hyperref titlesec xstring geometry fancyhdr etoolbox

# Stage 3: Final Image
FROM alpine:latest

WORKDIR /latex

# Copy only the necessary parts of TeX Live
COPY --from=builder /usr/share/texmf-dist /usr/share/texmf-dist
COPY --from=builder /usr/bin/latexmk /usr/bin/latexmk
COPY --from=builder /usr/bin/xelatex /usr/bin/xelatex
# Copy necessary files
COPY --from=builder-fonts /usr/local/texlive/2023/texmf-dist /usr/local/texlive/2023/texmf-dist
COPY --from=builder-fonts /usr/local/texlive/2023/bin/x86_64-linux/xelatex /usr/local/texlive/2023/bin/x86_64-linux/xelatex
COPY --from=builder-fonts /usr/local/texlive/2023/bin/x86_64-linux/latexmk /usr/local/texlive/2023/bin/x86_64-linux/latexmk

# Copy your project files AFTER the TeX Live setup
ENV PATH="/usr/local/texlive/2023/bin/x86_64-linux:$PATH"
COPY entrypoint.sh /entrypoint.sh
COPY *.tex *.bib *.cls /latex/
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
53 changes: 18 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,51 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Check for relevant changes
id: changes
run: |
CHANGED=0
git fetch origin main
if [[ $(git diff --name-only origin/main HEAD) =~ ^(\.docker\/|.*\.tex$|.*\.sty$|.*\.cls$) ]]; then
CHANGED=1
fi
echo "changed=${CHANGED}" >> $GITHUB_OUTPUT
- name: Set up Docker
if: steps.changes.outputs.changed == '1'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: steps.changes.outputs.changed == '1'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and cache Docker image
if: steps.changes.outputs.changed == '1'
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .docker
context: .
push: true
tags: ghcr.io/${{ github.repository }}/latex-builder:latest
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:(buildcache,latest)
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:buildcache,mode=max
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:latest
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:latest,mode=max

- name: Build LaTeX document
if: steps.changes.outputs.changed == '1'
run: |
docker run --rm -v ${{ github.workspace }}:/latex \
ghcr.io/${{ github.repository }}/latex-builder:latest \
main.tex "Anish_Shobith_P_S_Resume.pdf"
/latex/entrypoint.sh "Anish_Shobith_P_S_Resume.pdf"
- name: Get current date
id: date
run: echo "date=$(date +'%d-%m-%Y')" >> $GITHUB_OUTPUT

- name: Get short SHA
id: sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Combine Metadata
id: metadata
run: |
echo "date=$(date +'%d-%m-%Y')" >> $GITHUB_OUTPUT
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Create Release
if: steps.changes.outputs.changed == '1' && github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: false
tag_name: v${{ steps.date.outputs.date }}
name: "Resume Update ${{ steps.date.outputs.date }}"
tag_name: v${{ steps.metadata.outputs.date }}
name: "Resume Update ${{ steps.metadata.outputs.date }}"
body: |
📄 Resume update for ${{ steps.date.outputs.date }}
📄 Resume update for ${{ steps.metadata.outputs.date }}
**Commit**: ${{ steps.sha.outputs.sha }}
**Commit**: ${{ steps.metadata.outputs.sha }}
**Branch**: main
[View PDF](https://github.com/${{ github.repository }}/releases/download/v${{ steps.date.outputs.date }}/Anish_Shobith_P_S_Resume.pdf)
files: |
Anish_Shobith_P_S_Resume.pdf
[View PDF](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.date }}/Anish_Shobith_P_S_Resume.pdf)
files: Anish_Shobith_P_S_Resume.pdf
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 670da75

Please sign in to comment.