-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (71 loc) · 2.19 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
name: CI
on:
pull_request:
branches: main
push:
branches: main
permissions:
contents: read
packages: write
concurrency:
group: ci-${{github.ref}}
cancel-in-progress: ${{github.ref != 'refs/heads/main'}}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Gather info
id: info
run: |
PACKAGE='ghcr.io/${{github.repository_owner}}/clang-format'
TAGS="${PACKAGE}:latest"
echo "##[set-output name=package;]${PACKAGE,,}"
echo "##[set-output name=tags;]${TAGS,,}"
- name: Checkout
uses: actions/[email protected]
- name: Set up docker buildx
id: buildx
uses: docker/[email protected]
with:
version: latest
- name: Set up cache
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: buildx-${{hashFiles('Dockerfile', '.dockerignore')}}
restore-keys: buildx-
- name: Build image
uses: docker/[email protected]
with:
builder: ${{steps.buildx.outputs.name}}
context: .
tags: ${{steps.info.outputs.tags}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
push: false
load: true
- name: Report image details
run: >
docker image history
--format "table {{.Size}}\t{{.CreatedBy}}"
${{steps.info.outputs.package}}
- name: Run tests
run: docker run ${{steps.info.outputs.package}} clang-format --version
- name: Login into registry
if: github.ref == 'refs/heads/main'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{github.token}}
- name: Push image
if: github.ref == 'refs/heads/main'
uses: docker/[email protected]
with:
builder: ${{steps.buildx.outputs.name}}
context: .
tags: ${{steps.info.outputs.tags}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
push: true