-
-
Notifications
You must be signed in to change notification settings - Fork 14
110 lines (103 loc) · 3.17 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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