-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (70 loc) · 2.68 KB
/
test.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
name: test
on:
push:
branches: ["**"]
pull_request:
workflow_dispatch:
inputs: # null for another event
skip:
type: boolean
default: false
permissions: {}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
# tool versions
# renovate: datasource=github-releases depName=docker/buildx
BUILDX_VERSION: v0.18.0
# renovate: datasource=github-releases depName=moby/buildkit
BUILDKIT_VERSION: v0.17.2
jobs:
test:
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- run: |
echo 'FROM scratch' > Dockerfile
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
with:
version: ${{ env.BUILDX_VERSION }}
driver-opts: image=moby/buildkit:${{ env.BUILDKIT_VERSION }}
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: test-meta
name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},suffix=-test
type=semver,pattern={{major}}.{{minor}},suffix=-test
type=semver,pattern={{major}},suffix=-test
type=edge,suffix=-test
type=ref,event=branch,suffix=-test
- id: build
name: Build and push Docker image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
file: 'test.Dockerfile'
push: ${{ github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.test-meta.outputs.tags }}
labels: ${{ steps.test-meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- if: ${{ github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch }}
name: Display image digest
run: |
name=$(cut --delimiter=',' --fields=1 <<< "$NAME")
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$name@$DIGEST" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
env:
NAME: ${{ fromJson(steps.build.outputs.metadata)['image.name'] }}
DIGEST: ${{ fromJson(steps.build.outputs.metadata)['containerimage.digest'] }}