This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (73 loc) · 2.08 KB
/
test-build.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
name: Test & Build
on: push
jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
GOEXPERIMENT: loopvar
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.x
check-latest: true
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Vet
run: go vet ./...
- name: Test
run: go test ./...
build:
name: Build
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
needs:
- test
permissions:
contents: read # required for checkout
id-token: write # mint AWS credentials through OIDC
packages: write
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile
image_name: source-template
env:
GOEXPERIMENT: loopvar
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/overmindtech/${{ matrix.image_name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: setup-builder
uses: docker/setup-buildx-action@v2
- name: Build and push
id: push
uses: docker/build-push-action@v4
with:
builder: ${{ steps.setup-builder.outputs.name }}
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
file: build/package/${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}