Skip to content

ci

ci #624

Workflow file for this run

name: ci
on:
push:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.10.1
- run: zig fmt --check *.zig src/**/*.zig
build_docker_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: create tag
run: |
IMAGE="ghcr.io/${{ github.repository }}"
SHA=${{ github.sha }}
IMAGE_LATEST="$IMAGE:latest"
IMAGE_SHA="$IMAGE:$SHA"
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
TAGS="$IMAGE_SHA,$IMAGE_LATEST"
else
TAGS=$IMAGE_SHA
fi
echo "IMAGE=$IMAGE" >> $GITHUB_ENV
echo "IMAGE_LATEST=$IMAGE_LATEST" >> $GITHUB_ENV
echo "IMAGE_SHA=$IMAGE_SHA" >> $GITHUB_ENV
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: get current date
id: date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Login GitHub Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image & save chache
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.TAGS }}
build-args: |
CACHE_DATE=${{ env.CURRENT_DATE }}
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
run_test_and_build_docs:
runs-on: ubuntu-latest
needs: build_docker_image
container:
image: ghcr.io/${{ github.repository }}:${{ github.sha }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:
- name: checkout
uses: actions/checkout@v3
with:
submodules: true
- run: git config --global --add safe.directory /__w/zigcv/zigcv
shell: bash
- run: zig version
- name: save zig-cache
id: docker_cache
uses: actions/cache@v3
with:
path: ./zig-cache
key: ${{ runner.os }}-zig-cache-${{ github.event.repository.updated_at }}
restore-keys: |
${{ runner.os }}-zig-cache-
- name: test and build docs
run: zig build test -Ddocs=${{ github.ref == 'refs/heads/main' }}
- name: build examples
run: zig build examples
- uses: actions/upload-pages-artifact@v1
if: github.ref == 'refs/heads/main'
with:
path: docs
deploy:
needs: run_test_and_build_docs
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1