-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (82 loc) · 2.5 KB
/
branch-pipeline.yaml
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
name: branch-pipeline
on:
push:
branches:
- main
- release-*
jobs:
test:
name: Test with Coverage
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Check out code
uses: actions/checkout@v4
- name: Install dependencies
run: |
go mod download
- name: Run Unit tests
run: |
make test
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: goveralls -coverprofile=coverage.txt -service=github
build:
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Check for [skip ci] in commit messages or PR title
id: check_skip_ci
run: |
if [[ "${{ github.event.head_commit.message }}" =~ \[skip\ ci\] ]] || [[ "${{ github.event.pull_request.title }}" =~ \[skip\ ci\] ]]; then
echo "CI skip detected, exiting."
exit 0
fi
- name: Generate tag
id: get_tag
run: |
if [ "${GITHUB_REF##*/}" = "main" ]; then
TAG_NAME="latest"
else
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
VERSION="${BRANCH_NAME#release-}"
LARGEST_TAG=$(git tag --merged $BRANCH_NAME --sort=-v:refname | grep $VERSION | head -n 1)
TAG_NAME="${LARGEST_TAG}-${GITHUB_SHA::7}"
fi
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker Setup Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: GitHub Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
file: ./build/Dockerfile
context: .
push: true
tags: |
${{ vars.DOCKER_USERNAME }}/redis-operator:${{ env.TAG_NAME }}
ghcr.io/${{ github.repository_owner }}/redis-operator:${{ env.TAG_NAME }}
platforms: linux/amd64,linux/arm64