-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (162 loc) · 5.36 KB
/
ci.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Main CI
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- "main"
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
cache-dependency-path: "**/go.sum"
- name: Run Vet for code static analysis
run: make vet
- name: Run Tests
run: make test
sanity-check:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup action.yaml for local test
run: |
sed -i "s/docker:\/\/jerry153fish\/git-delta:$(cat version.txt)/Dockerfile/g" action.yaml
- name: Get Delta against main environment online mode
uses: ./
id: delta-env-online
with:
environment: main
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Print Delta Output for environment online
run: |
echo "Delta environment online flag: ${{ steps.delta-env-online.outputs.is_detected }}"
echo "Delta environment online files: ${{ steps.delta-env-online.outputs.delta_files }}"
- name: Get Delta against main environment offline mode (still need to query environment via API)
uses: ./
id: delta-env-offline
with:
environment: main
online: false
github_token: ${{ secrets.GITHUB_TOKEN }}
includes: |
**/*
excludes: |
**/*_test.go
- name: Print Delta Output for environment offline
run: |
echo "Delta environment offline flag: ${{ steps.delta-env-offline.outputs.is_detected }}"
echo "Delta Environment offline files: ${{ steps.delta-env-offline.outputs.delta_files }}"
- name: Get Delta against main branch with online mode
uses: ./
id: delta-branch-online
with:
branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}
includes: |
internal/**/*
.github/**/*
- name: Print Delta Output for branch online
run: |
echo "Delta branch online flag: ${{ steps.delta-branch-online.outputs.is_detected }}"
echo "Delta branch online files: ${{ steps.delta-branch-online.outputs.delta_files }}"
- name: Get Delta against main branch with offline mode
uses: ./
id: delta-branch-offline
with:
branch: main
online: false
github_token: ${{ secrets.GITHUB_TOKEN }}
includes: |
internal/**/*
.github/**/*
excludes: |
**/*.md
- name: Print Delta Output for branch offline
run: |
echo "Delta branch offline flag: ${{ steps.delta-branch-offline.outputs.is_detected }}"
echo "Delta branch offline: ${{ steps.delta-branch-offline.outputs.delta_files }}"
- name: Restore action.yaml
if: always()
run: |
sed -i "s/Dockerfile/docker:\/\/jerry153fish\/git-delta:$(cat version.txt)/g" action.yaml || true
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
cache-dependency-path: "**/go.sum"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
docker-push:
runs-on: ubuntu-latest
timeout-minutes: 60
if: ${{ github.event_name != 'pull_request' }}
environment: main
needs: [test, golangci, sanity-check]
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# setup Docker buld action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-
buildx-
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: jerry153fish/git-delta
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
tags: |
${{ github.ref != 'refs/heads/main' && steps.meta.outputs.tags || '' }}
${{ github.ref == 'refs/heads/main' && 'jerry153fish/remote-delta:latest' || '' }}
labels: ${{ steps.meta.outputs.labels }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
platforms: linux/amd64,linux/arm64
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache