Skip to content

Commit

Permalink
chore(ci): use docker/setup-buildx-action
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-cheng committed Apr 7, 2024
1 parent 52ff075 commit 8043420
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
pull_request:
schedule:
- cron: '0 0 1 * *'
- cron: "0 0 1 * *"
workflow_dispatch:
inputs:
deploy:
Expand All @@ -19,19 +19,23 @@ jobs:
runs-on: ubuntu-latest
env:
SCHEME: ${{ matrix.scheme }}
TAG: ghcr.io/xu-cheng/texlive-${{ matrix.scheme }}
steps:
- name: Set up Git repository
uses: actions/checkout@v3
- name: Enable Docker experimental features and setup DNS
- name: Get version
run: |
jq '.experimental=true | .dns=["1.1.1.1"]' /etc/docker/daemon.json > daemon.json
sudo mv daemon.json /etc/docker/daemon.json
sudo systemctl restart docker
docker version -f '{{.Server.Experimental}}'
echo "VERSION=$(date "+%Y%m%d")" >> "$GITHUB_ENV"
- name: Set up Git repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
run: |
docker build --squash -t texlive-$SCHEME --build-arg scheme=$SCHEME .
- name: Test
uses: docker/build-push-action@v5
with:
context: .
build-args: scheme=${{ env.SCHEME }}
load: true
tags: texlive-${{ env.SCHEME }}
- name: Test pdflatex
run: |
docker run --rm texlive-$SCHEME pdflatex --version
cat <<EOF >test.tex
Expand All @@ -54,15 +58,18 @@ jobs:
EOF
docker run --rm -v $(pwd):/data -w /data texlive-$SCHEME latexindent test.tex
if: "matrix.scheme == 'full'"
- name: Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}
if: "github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.deploy))"
- name: Deploy
run: |
TAG="ghcr.io/xu-cheng/texlive-$SCHEME"
VERSION="$(date "+%Y%m%d")"
docker tag texlive-$SCHEME $TAG:$VERSION
docker tag texlive-$SCHEME $TAG:latest
docker images $TAG
echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push $TAG:$VERSION
docker push $TAG:latest
uses: docker/build-push-action@v5
with:
context: .
build-args: scheme=${{ env.SCHEME }}
push: true
tags: ${{ env.TAG }}:${{ env.VERSION }},${{ env.TAG }}:latest
if: "github.ref == 'refs/heads/master' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.deploy))"

0 comments on commit 8043420

Please sign in to comment.